www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 16095] New: a delegate can mutate immutable data

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

          Issue ID: 16095
           Summary: a delegate can mutate immutable data
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: gmanev72 hotmail.com

the following code shows how one could mutate an immutable object:

      struct Foo {
         bool flag;
         void flip() {
            flag = true;
         }
      }

      immutable Foo foo;
      (&foo.flip)();
      assert(!foo.flag); //fails

--
May 30 2016