digitalmars.D.bugs - [Issue 18575] New: making delegate from member function can lead to
- d-bugmail puremagic.com (32/32) Mar 07 2018 https://issues.dlang.org/show_bug.cgi?id=18575
https://issues.dlang.org/show_bug.cgi?id=18575 Issue ID: 18575 Summary: making delegate from member function can lead to unsafe code Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: bugzilla digitalmars.com As reported by Tomer Filiba: safe: struct S { safe: int x; auto foo() {return &bar;} void bar() {x = 999;} } auto f() { auto s = S(100); return s.foo(); } void main() { auto dg = f(); dg(); // i now have a delegate that will write 999 to some random stack location } --
Mar 07 2018