Bug 24630 – Casting a bool pointer to a mutable pointer type is unsafe

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2024-06-25T19:45:41Z
Last change time
2024-06-25T23:05:14Z
Keywords
pull
Assigned to
No Owner
Creator
Nick Treleaven

Comments

Comment #0 by nick — 2024-06-25T19:45:41Z
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.
Comment #1 by dlang-bot — 2024-06-25T19:58:20Z
@ntrel created dlang/dmd pull request #16622 "Fix Bugzilla 24630 - Casting a bool pointer to a mutable pointer type…" fixing this issue: - Fix Bugzilla 24630 - Casting a bool pointer to a mutable pointer type is unsafe https://github.com/dlang/dmd/pull/16622
Comment #2 by dlang-bot — 2024-06-25T23:05:14Z
dlang/dmd pull request #16622 "Fix Bugzilla 24630 - Casting a bool pointer to a mutable pointer type…" was merged into master: - 8284e2926c321b25fdf82f39d33930760e532df2 by Nick Treleaven: Fix Bugzilla 24630 - Casting a bool pointer to a mutable pointer type is unsafe https://github.com/dlang/dmd/pull/16622