www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13537] New: Unions may break immutability

https://issues.dlang.org/show_bug.cgi?id=13537

          Issue ID: 13537
           Summary: Unions may break immutability
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: hsteoh quickfur.ath.cx

------
void fun()  safe {
        union U {
                immutable int x;
                int y;
        } 
        U u;
        u.y = 1;
        assert(u.x == 1);
        u.y = 2;
        assert(u.x == 2); // look ma! I broke immutability!
}
------

--
Sep 26 2014