www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22185] New: std.array.array() doesn't handle throwing element


          Issue ID: 22185
           Summary: std.array.array() doesn't handle throwing element
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: kinke gmx.net

If the source range has a length, it allocates an uninitialized array and fills
it with copies. If a copy throws (throwing postblit/copy constructor), that
element and the following ones are in no well-defined state, and if the element
type has a destructor, the GC will eventually try to destruct garbage elements.

Relevant code:

It should probably use new `core.lifetime.copyEmplace()` too.

Analogous to druntime issue https://issues.dlang.org/show_bug.cgi?id=21983.

Aug 06 2021