https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95971
--- Comment #9 from Jan Ziak (http://atom-symbol.net) <0xe2.0x9a.0x9b at gmail dot com> --- (In reply to Martin Liška from comment #8) > Or you can use -fno-finite-loops option. I am sorry, but I cannot trust this compiler not to force me again spending several hours of time just to learn that -O2 is semantically different from -O1 and -O3. The meaning of "semantically equivalent" in my mind is different from the meaning of "semantically equivalent" in your mind. Infinite loopiness is in my opinion semantically significant, so the compiler should have printed a warning that would inform me about the fact that the compiler is changing the semantics of the code in question. With -O3, the assembly code is: Dump of assembler code for function main: <+0>: sub $0x8,%rsp <+4>: xor %edi,%edi <+6>: callq xbool(bool) <+11>: jmp main+11 "11: jmp 11" is a prime example of what -ffinite-loops is supposed to prevent from being generated. Assuming that -O3 actually does include -ffinite-loops, which I am unable to verify because "g++ --help=optimizers -Q" doesn't accept the -std=gnu++11 option.