[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


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

          Issue ID: 22337
           Summary: `std.container.Array` object leak (on failed
                    construction)
           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

`std.container.Array`:

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:
https://github.com/dlang/phobos/pull/8162.

--


More information about the Digitalmars-d-bugs mailing list