Bug 19880 – delegate using lazy parameter breaks @safe

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2019-05-16T12:50:17Z
Last change time
2019-05-16T13:03:18Z
Keywords
safe
Assigned to
No Owner
Creator
Simen Kjaeraas

Comments

Comment #0 by simen.kjaras — 2019-05-16T12:50:17Z
@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.
Comment #1 by ag0aep6g — 2019-05-16T13:03:18Z
*** This issue has been marked as a duplicate of issue 11044 ***