https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101955
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- (In reply to Andreas Schwab from comment #2) > If you want to be agressive you can optimize f to return 0. In the middle-end? No, whether it is well defined or undefined depends heavily on the C/C++ version. At least ubsan flags it only with C99..C2X, not in C89 nor any C++ versions for b 1. For b -1 flaged in C99..C2X and C++11..C++17. C89, C++98 and C++20..C++23 accept that. Similarly for b > 1, flagged in C99..C2x and C++11..C++17 only.