| Liste des Groupes | Revenir à cl c |
On 01/06/2026 00:54, Keith Thompson wrote:[...]
(INT_MIN + INT_MAX) + 1 is well defined. (INT_MIN + INT_MAX) +1
is equivalent, and is also well defined. INT_MIN + (INT_MAX +1)
has undefined behavior.
Compilers can re-arrange integer arithmetic, despite new overflows, if
they know the result is the same. On pretty much any current
processor, a compiler generating code for integer "a + b + c" could do
the additions in any order - treating the operations as commutative
and fully associative. The final result will be the same in every
case where the original expression did not overflow (i.e., every case
with defined behaviour).
Les messages affichés proviennent d'usenet.