https://issues.dlang.org/show_bug.cgi?id=18567
--- Comment #2 from [email protected] --- Well, the compiler is just compiling the code differently now (which it can do, as it exhibits UB), the CSE is pretty easy to defeat though: void main(){ int i = 0; struct S{ const(int)* fun()const pure{ return &i; } } immutable S s; static const(int)* foo(immutable(S) s)pure{ return s.fun(); } immutable(int) *pi=foo(s); import std.stdio; writeln(*pi); // 0 i+=1; int x=*pi; writeln(x); // 1 } The problem is that this line compiles: immutable S s; This requires an immutable context pointer, but a mutable one is provided. In general, context pointers should be type checked essentially as if we were passing around explicit pointers. --
