import std.stdio;

    struct A {
        this(this) {
            writeln("A.this(this)");
        }

        B b1, b2;
    }

    struct B {
        this(this) {
            writeln("B.this(this)");
        }
    }

    void main() {
        A a, b;
        a = b;
    }

This outputs:

    B.this(this)
    B.this(this)
    A.this(this)

Now, http://dlang.org/struct.html#AssignOverload says:

    ref S opAssign(S s)
    {
      S tmp = this;   // bitcopy this into tmp
      this = s;       // bitcopy s into this
      tmp.__dtor();   // call destructor on tmp
      return this;
    }

Note the term "bitcopy", which for me implies that no postblits are supposed to be called.

What the compiler does makes sense to me, but it seems to contradict the documentation. I guess the call to the postblit is missing in the pseudo-code... Am I right?

(DMD git 514db2e212ae52e1206d4296e48d4a689370d04b)

Reply via email to