[Bug other/95971] [10 regression] Optimizer converts a false boolean value into a true boolean value
0xe2.0x9a.0x9b at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jun 29 20:50:30 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95971
--- Comment #10 from Jan Ziak (http://atom-symbol.net) <0xe2.0x9a.0x9b at gmail dot com> ---
I hope you do realize that the code I posted previously is equivalent, or very
close to being equivalent, to the following code:
struct President {
const bool dead = false;
bool isDead() { return dead; }
} president;
while(!president.isDead());
if(president.isDead()) {
launch_retaliation_nukes();
}
With -ffinite-loops enabled, the nukes are going to be launched because the
only way that the while-loop can terminate is for President::dead to be true
and thus the "const bool dead" can be assumed to be true when execution reaches
the if-statement after skipping the deleted infinite while loop.
More information about the Gcc-bugs
mailing list