https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102303
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- No, the issue is that we apply constant folding and elide the trapping operation which is generally considered OK by GCC (eliding traps, that is). For example we also elide the trap in int main() { int n = 0x7fffffff; n+1; return 0; } I would advise against the use of -ftrapv and instead use -fsanitize=signed-integer-overflow -fsanitize-undefined-trap-on-error