www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14321] New: No postblit call with struct and AA's

https://issues.dlang.org/show_bug.cgi?id=14321

          Issue ID: 14321
           Summary: No postblit call with struct and AA's
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: rswhite4 gmail.com

Code:
----
import std.stdio;

struct Foo {
    this(int id) {
        writeln("CTor");
    }

    this(this) {
        writeln("Postblit");
    }

    ~this() {
        writeln("DTor");
    }
}

void main() {
    Foo[string] foos;
    foos["test"] = Foo(42);

    writeln("end of main");
}
----

Expected behaviour
----
CTor
end of main
----

or

----
CTor
Postblit
DTor
end of main
----

But currently:
----
CTor
DTor
end of main
----

That ruins all interaction between AA's and ref counted structs.

--
Mar 23 2015