[Issue 24434] New: Casting away const with cast() should not produce an lvalue
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sun Mar 10 19:28:46 UTC 2024
    
    
  
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 at puremagic.com
          Reporter: bugzilla at 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
--
    
    
More information about the Digitalmars-d-bugs
mailing list