[Issue 21983] New: dup leaves a partially constructed array if postblit/copy ctor throws

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri May 28 15:21:35 UTC 2021


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: nobody at puremagic.com
          Reporter: moonlightsentinel at disroot.org

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).

--


More information about the Digitalmars-d-bugs mailing list