[Issue 22337] New: `std.container.Array` object leak (on failed construction)

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Sep 27 12:18:59 UTC 2021


          Issue ID: 22337
           Summary: `std.container.Array` object leak (on failed
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: adder.thief+1 at gmail.com


The constructor taking variadic arguments (which is used in e.g.: `auto a =
Array (S (0), S (1), S (2), S(3));`:

If `emplace`-ing one of the given elements in the newly-created `Array` fails
(by `throw`-ing an `Exception`), the construction of the `Array` fails (by
propagating the `Exception`) (and this is correct), but the already-`emplace`-d
elements are not destroyed (and this is incorrect).

Details and `unittest` and proposed fix:


More information about the Digitalmars-d-bugs mailing list