https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119543
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- >This bug appears to be related to how the compiler handles signed integer >overflow. YES and that behavior is undefined then. "The compiler may incorrectly assume this overflow case never happens due to undefined behavior rules in C, leading to the wrong optimization of always returning 0." There is NO wrong optimization happening here. You invoked undefined behavior. Please https://blog.regehr.org/archives/213 and others.