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);
}
 Permalink
Permalink Reply
Reply