This code show an issue of const/immutable/shared correctness:
----------------------------------------------------
class A
{
int x;
void foo() { x++; }
}
void main()
{
auto a = new immutable(A);
auto x = a.x;
auto dg = &a.foo; // NG: immutable instance of A has been converted implicitly to mutable instance of A
dg(); // NG: immutable memory field is broken.
auto y = a.x;
assert(x == y); // NG: 0 == 1
}
----------------------------------------------------
Similar issue:
----------------------------------------------------
class B
{
void bar() shared { }
}
void main()
{
auto b = new B;
auto dg = &b.bar; // NG: unshared instance of B has been converted implicitly to shared instance of B
}
----------------------------------------------------
Comment #1 by k.hara.pg — 2013-07-26T10:21:27Z
*** This issue has been marked as a duplicate of issue 1983 ***