Re:GCC 6.1 Released
by anttihaapala on Thursday April 28, 2016 @04:46AM
(#11587325)
And of course the code is wrong, because the behaviour is undefined - in 64-bit architectures it is very common to use 64-bit registers for `int` even if in memory `sizeof(int) == 4`; thus `int a = INT_MAX;`, `a + 100` could still be greater than `INT_MAX`.
Overflow checking is sometimes done like this (where a is a signed integer):
Of course this invokes undefined behavior, and some people get angry when compilers remove the check: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30475