[Issue 8781] New: delegate breaks const/immutable/shared correctness

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Oct 8 03:55:26 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8781

           Summary: delegate breaks const/immutable/shared correctness
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: zan77137 at nifty.com


--- Comment #0 from SHOO <zan77137 at nifty.com> 2012-10-08 03:37:27 PDT ---
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
}
----------------------------------------------------

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list