https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102279
--- Comment #1 from Richard Earnshaw <rearnsha at gcc dot gnu.org> --- Looks to me like this code violates the aliasing rules. Compiling with -fno-strict-aliasing looks generate what your are expecting (although your expectations are wrong by the C standard). Oddly, -Wstrict-aliasing does not pick this case up, perhaps because of the packed attribute.