[Issue 13085] New: Compiler does not reject storing global reference to scope delegate
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Jul 9 15:16:33 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13085
Issue ID: 13085
Summary: Compiler does not reject storing global reference to
scope delegate
Product: D
Version: D2
Hardware: x86
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: hsteoh at quickfur.ath.cx
Code:
------
int delegate() globDg;
void func(scope int delegate() dg) {
globDg = dg;
globDg();
}
void sub() {
int x;
func(() { return ++x; });
}
void trashme() {
import std.stdio;
writeln(globDg()); // prints garbage
}
void main() {
sub();
trashme();
}
------
--
More information about the Digitalmars-d-bugs
mailing list