digitalmars.D.bugs - [Issue 21720] New: Struct with destructor cannot be emplaced in
- d-bugmail puremagic.com (39/39) Mar 15 2021 https://issues.dlang.org/show_bug.cgi?id=21720
https://issues.dlang.org/show_bug.cgi?id=21720 Issue ID: 21720 Summary: Struct with destructor cannot be emplaced in betterC Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: regression Priority: P1 Component: druntime Assignee: nobody puremagic.com Reporter: chalucha gmail.com Reduced test case: ```D import core.stdc.stdlib : malloc; import core.lifetime : emplace; struct Foo { size_t foo; ~this() { } // works with this line commented out } extern(C) void main() { auto p = malloc(Foo.sizeof); Foo* pay = emplace!Foo(p[0..Foo.sizeof], 1); } ``` dmd -betterC test.d returns: /home/tomas/dlang/dmd-2.096.0/linux/bin64/../../src/druntime/import/core/internal/lifetime.d(35): Error: Cannot use try-catch statements with -betterC /home/tomas/dlang/dmd-2.096.0/linux/bin64/../../src/druntime/import/core/internal/lifetime.d(57): Error: template instance `core.internal.lifetime.emplaceRef!(Foo, Foo, int).emplaceRef.S.__ctor!()` error instantiating /home/tomas/dlang/dmd-2.096.0/linux/bin64/../../src/druntime/import/core/lifetime.d(299): instantiated from here: `emplaceRef!(Foo, Foo, int)` test.d(13): instantiated from here: `emplace!(Foo, int)` This worked with previous compilers. --
Mar 15 2021