[Issue 12941] Everything should be @unsafe by default, and explicitly vetted (and documented) as @safe
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Jun 19 16:27:13 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12941
--- Comment #8 from hsteoh at quickfur.ath.cx ---
Furthermore, delegates that close over struct members are @system if the
closure leaves the construction scope, for example:
struct S {
int x;
void delegate() dg;
this() {
dg = (){ x++; }; // N.B. closure over x
}
}
S makeS() {
return S(); // oops -- S may get moved during 'return'
}
void main() {
auto s = makeS();
s.dg(); // memory corruption
}
--
More information about the Digitalmars-d-bugs
mailing list