https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79373
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |ebotcazou at gcc dot gnu.org --- Comment #8 from Eric Botcazou <ebotcazou at gcc dot gnu.org> --- > I do understand that this is what happens (the code is fixed by promoting > int32_t t=x to int64_t t=x) but the undefined behavior affects a variable > (and its associated comparison) that should not be affected by it. No, undefined behavior is not a bounded error in C or C++, which means that the compiler doesn't have to control it; in other words, once it is reached at run time, the entire program can be wrecked. Other languages, e.g. Ada, have a notion of bounded error, which means the the compiler must control it somehow.