https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89670
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |jakub at gcc dot gnu.org Resolution|--- |INVALID --- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> --- __builtin_ctz (0) is undefined behavior, anytime you invoke UB, all bets are off. The compiler optimizes based on the assumption that UB does not happen. So, as all valid __builtin_ctz calls return values from 0 to 31, the compiler does optimize away __builtin_ctz (x) == 32 into 0.