www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - moveToGC

reply JG <someone somewhere.com> writes:
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);


     }
May 10
next sibling parent reply Mike Parker <aldacron gmail.com> writes:
On Monday, 10 May 2021 at 10:56:35 UTC, JG wrote:
 The following compiles with dmd but not with ldc on 
 run.dlang.io. Am I doing something wrong?
Please provide the error message(s) when asking questions like this. In this case: ``` onlineapp.d(15): Error: undefined identifier moveToGC onlineapp.d(20): Error: undefined identifier moveToGC ``` Looks like moveToGC was added in 2.096: https://github.com/dlang/druntime/commit/bf59d2dcc4eae068a37db169977eef3eb394cee6 Adding --version to the ldc command line at run.dlang.io shows it's running ldc 1.25.1, which is current with D 2.095.1.
May 10
parent JG <someone somewhere.com> writes:
On Monday, 10 May 2021 at 11:11:06 UTC, Mike Parker wrote:
 On Monday, 10 May 2021 at 10:56:35 UTC, JG wrote:
 The following compiles with dmd but not with ldc on 
 run.dlang.io. Am I doing something wrong?
Please provide the error message(s) when asking questions like this. In this case: ``` onlineapp.d(15): Error: undefined identifier moveToGC onlineapp.d(20): Error: undefined identifier moveToGC ``` Looks like moveToGC was added in 2.096: https://github.com/dlang/druntime/commit/bf59d2dcc4eae068a37db169977eef3eb394cee6 Adding --version to the ldc command line at run.dlang.io shows it's running ldc 1.25.1, which is current with D 2.095.1.
Thank you.
May 12
prev sibling parent Alain De Vos <devosalain ymail.com> writes:
Something else with,
import core.memory i've got,
undefined identifier moveToGC
May 10