[expr.pre] (original) (raw)

[Note 4:

The implementation can regroup operators according to the usual mathematical rules only where the operators really are associative or commutative.40

For example, in the following fragmentint a, b; a = a + 32760 + b + 5;the expression statement behaves exactly the same asa = (((a + 32760) + b) + 5);due to the associativity and precedence of these operators.

Thus, the result of the sum (a + 32760) is next added to b, and that result is then added to 5 which results in the value assigned toa.

On a machine in which overflows produce an exception and in which the range of values representable by an int is [-32768, +32767], the implementation cannot rewrite this expression asa = ((a + b) + 32765);since if the values for a and b were, respectively, and , the sum a + b would produce an exception while the original expression would not; nor can the expression be rewritten as eithera = ((a + 32765) + b);ora = (a + (b + 32765));since the values for a and b might have been, respectively, 4 and or 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_]