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: nob...@puremagic.com Reporter: timon.g...@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 } --- --