www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24434] New: Casting away const with cast() should not produce

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

          Issue ID: 24434
           Summary: Casting away const with cast() should not produce an
                    lvalue
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

This should not compile:

   safe:

  void main() {
    const int i = 3;
    int* q = &cast()i; // this should not compile in  safe code
    *q = 4; // oops
    bar(i);
  }

  void bar(ref const int i) { assert(i == 3); } // fails at runtime

--
Mar 10