← Back to index
|
Original Bugzilla link
Bug 22185 – std.array.array() doesn't handle throwing element copying
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-08-06T13:21:38Z
Last change time
2022-01-26T11:25:07Z
Keywords
pull
Assigned to
No Owner
Creator
kinke
Comments
Comment #0
by kinke — 2021-08-06T13:21:38Z
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:
https://github.com/dlang/phobos/blob/ccecbda25f1114bca2782c971e7d47cf65abd825/std/array.d#L126-L134
It should probably use new `core.lifetime.copyEmplace()` too. Analogous to druntime issue
https://issues.dlang.org/show_bug.cgi?id=21983.
Comment #1
by dlang-bot — 2022-01-14T22:35:52Z
@maxhaton created dlang/phobos pull request #8359 "Fixes issues 22185, 22673" fixing this issue: - Fixes issues 22185, 22673
https://github.com/dlang/phobos/pull/8359
Comment #2
by dlang-bot — 2022-01-26T11:25:07Z
dlang/phobos pull request #8359 "Fixes issues 22185, 22673" was merged into master: - 4eff7e2a312f70cd5a576bcfdd63d8b0022c68b4 by Max Haughton: Fixes issues 22185, 22673
https://github.com/dlang/phobos/pull/8359