[Issue 24477] New: Union access of bool shouldn't be allowed in @safe
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 1 21:34:25 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24477
Issue ID: 24477
Summary: Union access of bool shouldn't be allowed in @safe
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: safe
Severity: normal
Priority: P3
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dkorpel at live.nl
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");
}
```
--
More information about the Digitalmars-d-bugs
mailing list