[Issue 5270] Using a scope delegate allows memory corruption in safe mode

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Jul 9 15:22:41 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=5270

--- Comment #4 from hsteoh at quickfur.ath.cx ---
Another failing case that illustrates the problem:
------
int delegate() globDg;

void func(scope int delegate() dg) {
        globDg = dg; // should be rejected but isn't
        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