[Issue 16095] New: a delegate can mutate immutable data

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon May 30 02:44:07 PDT 2016


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 at puremagic.com
          Reporter: gmanev72 at 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

--


More information about the Digitalmars-d-bugs mailing list