The implementation may regroup operators according to
the usual mathematical rules only
where the operators really are associative or commutative.
For example, in the following fragment
int a, b;
a = a + 32760 + b + 5;
the expression statement behaves exactly the same as
a = (((a + 32760) + b) + 5);
due to the associativity and precedence of these operators.
result of the sum (a + 32760)
is next added to b
that result is then added to 5 which results in the value assigned to
On a machine in which overflows produce an exception and in
which the range of values representable by an int
], the implementation cannot rewrite this
a = ((a + b) + 32765);
since if the values for a
-32754 and -15, the sum a + b
would produce an exception while
the original expression would not; nor can the expression be rewritten
a = ((a + 32765) + b);
a = (a + (b + 32765));
since the values for a
might have been,
respectively, 4 and -8 or -17 and 12.
However on a machine in which
overflows do not produce an exception and in which the results of
overflows are reversible, the above expression statement can be
rewritten by the implementation in any of the above ways because the
same result will occur.
— end note