May 25, 2023
https://issues.dlang.org/show_bug.cgi?id=23937

          Issue ID: 23937
           Summary: LDC with -nogc and DMD object.destroy
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: major
          Priority: P1
         Component: druntime
          Assignee: nobody@puremagic.com
          Reporter: black80@bk.ru

code is totally @nogc

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
import std, core.lifetime;

class C {
@nogc:
        long v;
        this() @nogc { "C.this()\n".printf; }
        ~this() @nogc { "C.~this()\n".printf; }
        void destroy() @nogc { "C.destroy()\n".printf; }
        void sayHi() @nogc { "hi\n".printf; }
}

void[ __traits(classInstanceSize, C)] tmem;

void main() @nogc {
        scope auto c = emplace!C( tmem );
        //scope( exit) destroy( c); // Error: `@nogc` function `D main` cannot
call non-@nogc function `object.destroy!(true, C).destroy`
        scope( exit) c.destroy(); // OK
        //scope( exit) c.~C(); // C++ style. doesnt compile

        c.sayHi();
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1) cannot call global ::destroy( obj) in @nogc context so used own one.
https://issues.dlang.org/show_bug.cgi?id=22174

2) code compiles w/o -nogc switch and get strange error with it. why so? \import\core\lifetime.d(107): Error: No implicit garbage collector calls allowed with -nogc option enabled: `_d_array_slice_copy`

--