https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93184
--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Shifts by negative values or larger or equal to the bitsize are undefined behavior. Once you invoke undefined behavior in a program, there is no discussion about what is correct and what is incorrect, the only incorrect thing is the program that lead to the undefined behavior, any behavior at that point is fine.