moveToGC

JG someone at somewhere.com
Mon May 10 10:56:35 UTC 2021


The following compiles with dmd but not with ldc on run.dlang.io. 
Am I doing something wrong?


import core.memory;

     void main()
     {

         struct S
         {
             int x;
             this(this) @disable;
             ~this() @safe pure nothrow @nogc {}
         }

         S* p;

         // rvalue
         p = moveToGC(S(123));
         assert(p.x == 123);

         // lvalue
         auto lval = S(456);
         p = moveToGC(lval);
         assert(p.x == 456);
         assert(lval.x == 0);


     }


More information about the Digitalmars-d-learn mailing list