https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91373
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- >If GCC need to follow rule, it should not be relative to GCC optimization. So there are two rules here getting involved. One is the implicit promoting to int. The second rule is that signed integer overflow is undefined. It is the second rule which you are running into. Gcc only takes into account the undefined behavior (at runtime) while compiling with optimization. If you want gcc to say signed integer to have defined behavior for overflow (wrapping), then you can use the -fwrapv option.