[Issue 17448] Move semantics cause memory corruption and cryptic bugs
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Mar 4 14:10:07 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=17448
--- Comment #22 from Tomer Filiba (weka) <tomer at weka.io> ---
void delegate() callback;
struct S {
int x;
@disable this(this);
this(int x) {
this.x = x;
callback = &inc;
}
void inc() {
x++;
}
}
auto f() {
return g();
}
auto g() {
return h();
}
auto h() {
return S(100);
}
void main() {
auto s = f();
writeln(&s, " ", callback.ptr); // 7FFF0C838400 7FFF0C8383A0
callback();
writeln(s.x); // 100 instead of 101
}
--
More information about the Digitalmars-d-bugs
mailing list