http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54972
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-10-18 11:31:59 UTC --- Apparently you didn't read http://gcc.gnu.org/bugs/ 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. And also the section on "Casting does not work as expected when optimization is turned on" at http://gcc.gnu.org/bugs/#nonbugs You should never report a bug without turning on warnings and seeing if the compiler can tell you where the problem is.