[Issue 24630] New: Casting a bool pointer to a mutable pointer type is unsafe
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Tue Jun 25 19:45:41 UTC 2024
    
    
  
https://issues.dlang.org/show_bug.cgi?id=24630
          Issue ID: 24630
           Summary: Casting a bool pointer to a mutable pointer type is
                    unsafe
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: nick at geany.org
Inverse of issue 24582.
    bool v;
    auto bp = cast(byte*) &v;
    *bp = 2; // v is now invalid
Same goes for runtime cast from bool[] to byte[]. If the target element type is
const then the cast is safe.
PR incoming.
--
    
    
More information about the Digitalmars-d-bugs
mailing list