Bug 8781 – delegate breaks const/immutable/shared correctness

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-10-08T03:37:00Z
Last change time
2013-07-26T10:21:27Z
Assigned to
nobody
Creator
zan77137

Comments

Comment #0 by zan77137 — 2012-10-08T03:37:27Z
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 ***