digitalmars.D.bugs - [Issue 19880] New: delegate using lazy parameter breaks safe
- d-bugmail puremagic.com (30/30) May 16 2019 https://issues.dlang.org/show_bug.cgi?id=19880
https://issues.dlang.org/show_bug.cgi?id=19880 Issue ID: 19880 Summary: delegate using lazy parameter breaks safe Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Keywords: safe Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: simen.kjaras gmail.com safe: int delegate() dg; void fun2(lazy int n) { dg = () => n; } void fun1() { int i = 0; fun2(i); } unittest { fun1(); assert(dg() == 0); } The above assert fails, as i goes out of scope when fun1 returns, but is still referenced by dg. --
May 16 2019