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: nob...@puremagic.com
        ReportedBy: zan77...@nifty.com


--- Comment #0 from SHOO <zan77...@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: -------

Reply via email to