3 ms·
> Worse, the compiler is entitled to use saturation arithmetic if you've assumed wrapping. C89 (draft[1], because the actual spec is not public) section 3.1.2.
by jstanley 7y ago
> Worse, the compiler is entitled to use saturation arithmetic if you've assumed wrapping.
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 http://port70.net/~nsz/c/c89/c89-draft.html
- ncmncm 7y agosigned 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.