digitalmars.D.bugs - [Issue 22547] New: .dup on array of nested structs can cause null
- d-bugmail puremagic.com (28/28) Nov 26 2021 https://issues.dlang.org/show_bug.cgi?id=22547
https://issues.dlang.org/show_bug.cgi?id=22547 Issue ID: 22547 Summary: .dup on array of nested structs can cause null dereference if copy throws Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: druntime Assignee: nobody puremagic.com Reporter: stanislav.blinov gmail.com As pointed out by kinke here: https://forum.dlang.org/post/yfiytdysalmauqadtvfy forum.dlang.org 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 --
Nov 26 2021