https://issues.dlang.org/show_bug.cgi?id=21983
Issue ID: 21983
Summary: dup leaves a partially constructed array if
postblit/copy ctor throws
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P1
Component: druntime
Assignee: [email protected]
Reporter: [email protected]
dup calls user-defined postblits/copy constructor when creating a new array.
But it doesn't destroy the partially constructed array when the postblit/copy
constructors throws an exception. The GC will destroy the array (including
uninitialized elements!) at an undefined time.
dup should destroy the initialized portion of the array and prevent the
destruction of uninitialized objects (e.g. by manually freeing the memory).
--