[Issue 20148] void initializated bool can be both true and false
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jun 5 23:44:42 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20148
--- Comment #3 from hsteoh at quickfur.ath.cx ---
Actually, as far as this bug is concerned, @safe is a red herring, and so is
void initialization.
Proof:
---------
bool schrodingersCat() @safe {
union U { bool b; int i; }
U u;
u.i = 2;
return u.b;
}
void main() @safe {
import std.stdio;
bool b = schrodingersCat();
if (b) writeln("alive");
if (!b) writeln("dead");
}
---------
Output:
---------
alive
dead
---------
Apparently, D semantics exhibit quantum mechanical effects!
--
More information about the Digitalmars-d-bugs
mailing list