[Issue 14245] Immutable reference to immutable field in constructor allows breaking type system
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Jun 6 04:24:15 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=14245
--- Comment #1 from Marc Schütz <schuetzm at gmx.net> ---
Full compilable and runnable example (main() was missing):
struct S {
immutable int x;
this(int a) {
import std.stdio;
immutable int* b = &this.x;
writeln(*b); // prints 0
this.x = a;
writeln(*b); // prints value of a
}
}
void main() {
S(10);
}
--
More information about the Digitalmars-d-bugs
mailing list