https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112442
--- Comment #7 from Xi Ruoyao <xry111 at gcc dot gnu.org> --- Note that in the "new bug" page, there is a red banner saying: Before reporting that GCC compiles your code incorrectly, compile it with gcc -Wall -Wextra and see whether this shows anything wrong with your code. Similarly, if compiling with -fno-strict-aliasing -fwrapv makes a difference, your code probably is not correct. In this case -fno-strict-aliasing makes a difference. And the code is indeed incorrect.