Quote:
Originally Posted by j.p.s
Reordering can be mathematically equivalent but still give significantly different computed results, especially if large and small quantities are present in the same expression.
|
Under the "as-if" rule, reordering shouldn't affect the computed results (so long as there's no undefined behaviour, such as signed overflow, going on). Some compilers have options to enable unsafe optimisations which might affect things if you're e.g. operating at the limits of floating point precision, so rounding errors mount up, and some may even default to those being turned on, but they must have a way of turning them off or they're not conforming.