Am 19.01.2014 18:48, schrieb Lemonfiend:
import std.stdio;

struct C
{
     A[] _objs;

     this(A[] objs...)
     {
         writeln(`  C this()`);
         _objs = objs;

         // A.this(this) is not called
         // yet A.~this IS called
     }
}

struct B
{
     A sup;
     alias sup this;

     this(A a)
     {
         writeln(count, ` B this()`);
         sup = a;
     }
}

struct A
{
     static int count;

     this(int n)
     {
         count++;
         writeln(count, ` A this()`);
     }

     this(this)
     {
         count++;
         writeln(count, ` A this(this)`);
     }

     ~this()
     {
         count--;
         writeln(count, ` A ~this()`);
     }
}

void main()
{
     A a = A(1);
     writeln(a.count == 1);

     B b = B(a);
     writeln(a.count == 2);

     C c = C(b);
     writeln(a.count == 3);
}


Yes this looks like a bug to me. Please file a bug report at https://d.puremagic.com/issues/

Kind Regards
Benjamin Thaut

Reply via email to