Re:Bounded Integer: Header-only C++ library replaces integer...
by ncmncm on Sunday September 29, 2019 @03:22PM
(#21109106)
signed and unsigned have different semantics.
The compiler is allowed to do literally anything on signed overflow, including launching the missiles, and not running the program. Or both.
C89 (draft[1], because the actual spec is not public) section 3.1.2.5 states:
> ... a result that cannot be represented by the resulting unsigned integer type is reduced modulo the number that is one greater than the largest value that can be represented by the resulting unsigned integer type.
So, unless I'm misunderstanding, the compiler is not entitled to use saturation arithmetic on unsigned integers.
[1] http://port70.net/~nsz/c/c89/c89-draft.html