Bug 24477 – Union access of bool shouldn't be allowed in @safe

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-04-01T21:34:25Z
Last change time
2024-04-03T02:52:37Z
Keywords
pull, safe
Assigned to
No Owner
Creator
Dennis

Comments

Comment #0 by dkorpel — 2024-04-01T21:34:25Z
See https://issues.dlang.org/show_bug.cgi?id=20148#c8 ``` bool schrodingersCat() @safe { union Box { bool b; ubyte y; } Box u; u.y = 2; return u.b; } void main() @safe { import std.stdio; bool b = schrodingersCat(); if (b) writeln("alive"); if (!b) writeln("dead"); } ```
Comment #1 by dlang-bot — 2024-04-01T21:37:59Z
@dkorpel created dlang/dmd pull request #16356 "Fix bugzilla 24477 - Union access of bool shouldn't be allowed in `@s…" fixing this issue: - Fix bugzilla 24477 - Union access of bool shouldn't be allowed in `@safe` https://github.com/dlang/dmd/pull/16356
Comment #2 by dlang-bot — 2024-04-03T02:52:37Z
dlang/dmd pull request #16356 "Fix bugzilla 24477 - Union access of bool shouldn't be allowed in `@s…" was merged into master: - fed655c9b59a2da97f1306f2c857e472874cc639 by Dennis Korpel: Fix bugzilla 24477 - Union access of bool shouldn't be allowed in `@safe` https://github.com/dlang/dmd/pull/16356