Bug 21720 – Struct with destructor cannot be emplaced in betterC

Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P1
Component
druntime
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2021-03-15T16:39:50Z
Last change time
2021-03-15T16:45:55Z
Assigned to
No Owner
Creator
Tomáš Chaloupka

Comments

Comment #0 by chalucha — 2021-03-15T16:39:50Z
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.
Comment #1 by moonlightsentinel — 2021-03-15T16:45:55Z
*** This issue has been marked as a duplicate of issue 21709 ***