www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24630] New: Casting a bool pointer to a mutable pointer type

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

--
Jun 25