Bug 22547 – .dup on array of nested structs can cause null dereference if copy throws

Status
NEW
Severity
normal
Priority
P3
Component
druntime
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-11-26T11:55:01Z
Last change time
2024-12-07T13:41:30Z
Assigned to
No Owner
Creator
Stanislav Blinov
Moved to GitHub: dmd#17198 →

Comments

Comment #0 by stanislav.blinov — 2021-11-26T11:55:01Z
As pointed out by @kinke here: https://forum.dlang.org/post/[email protected] void main() { int i; struct S { // A copy ctor won't currently compile (dmd 2.098) // due to "cannot access stack frame pointer..." this(this) { throw new Exception("!!!"); } ~this() { ++i; } } auto a1 = [ S() ]; auto a2 = a1.dup; // throws } // segmentation fault when destructing a2 because a2[0].tupleof[$-1] is null
Comment #1 by robert.schadek — 2024-12-07T13:41:30Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17198 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB