[Issue 22864] [REG 2.067] Throwing in array literal leads to destructor being called on unconstructed data

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Mar 23 10:58:48 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=22864

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305 at gmail.com

--- Comment #1 from RazvanN <razvan.nitu1305 at gmail.com> ---
This is a gluelayer problem (common for all 3 backends). I haven't looked at
what gdc and ldc do, but in dmd the gluelayer first inserts a call to
_d_arrayliteral (which allocates the array with the gc) and then it calls
getS(). Look ma! I even got the code to prove it:
https://github.com/dlang/dmd/blob/master/src/dmd/e2ir.d#L4834.  I assume that
this is what gdc and ldc do also, so it's not a frontend bug.

The solution could be to first store the initializers on the stack and memcpy
them after we allocate the array (essentially, the else branch of the verion in
the original report).

--


More information about the Digitalmars-d-bugs mailing list