https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90882
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Since it is undefined behavior both GCC and clang are correct. -fsanitizer=undefined can be detect it at runtime. This code is undefined in two different ways really. you also violate C aliasing rules (though it is turned off until -O2 and above).