[Issue 19880] New: delegate using lazy parameter breaks @safe
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu May 16 12:50:17 UTC 2019
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 at puremagic.com
Reporter: simen.kjaras at 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.
--
More information about the Digitalmars-d-bugs
mailing list