April 01 [Issue 24477] New: Union access of bool shouldn't be allowed in @safe | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: dkorpel@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"); } ``` -- |
Copyright © 1999-2021 by the D Language Foundation