mr********@gmail.com wrote:
Because precedence and order-of-evaluation are unrelated.
Ok... what's the difference, then?
Glen
If you don't concern yourself with such things like overflow,
precedence determines the logic, while order of execution is
at the liberty of the optimizer.
unsigned a, b, c; // no overflow
...
unsigned d = a + b - c;
'+' and '-' have the same precedence and while they are usually
grouped from left to right, the compiler is free to evaluate the
above expression as if it were written
unsigned d = a + (b - c);
or
unsigned d = (a - c) + b;
In that context we say that the order of execution is unspecified.
That's how I see it anyway. A proper book on on computer science
must explain it better.
V
--
Please remove capital As from my address when replying by mail