digitalmars.D.bugs - [Issue 23145] New: Stack allocation of scope variables defeats safe
- d-bugmail puremagic.com (38/38) May 28 2022 https://issues.dlang.org/show_bug.cgi?id=23145
https://issues.dlang.org/show_bug.cgi?id=23145 Issue ID: 23145 Summary: Stack allocation of scope variables defeats safe Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: safe Severity: major Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: timon.gehr gmx.ch DMD v2.100.0 Compiles even with -dip1000: --- class D{ C c; } class C { D d; int x=3; this(D d) safe nogc{ d.c=this; this.d=d; } } C foo(D d) nogc safe{ scope c = new C(d); // remove `scope` and program does not crash return c.d.c; // escape c } void main(){ import std.stdio; writeln(foo(new D)); // segfault } --- --
May 28 2022