[Issue 22547] New: .dup on array of nested structs can cause null dereference if copy throws
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Nov 26 11:55:01 UTC 2021
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 at puremagic.com
Reporter: stanislav.blinov at 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
--
More information about the Digitalmars-d-bugs
mailing list