R
Richard Heathfield
Peter Nilsson said:
I didn't point out any such thing. The associativity determines which
operands are used with which operators. That isn't the same as implying
an order of evaluation. Any evaluation ordering that happens to fall
out of an expression syntax is purely a consequence of reality, and has
nothing to do with the rules of C.
If the values are initially, say, these:
i = 1;
j = -1;
k = INT_MIN;
then there is a real difference in the abstract machine, too.
Why? Precedence looks perfectly adequate here.
The order of sub-expressions is unspecified, except for ||, &&
and ?: operators. As you point out yourself, there is an implied
ordering of the + operations from the associativity.
I didn't point out any such thing. The associativity determines which
operands are used with which operators. That isn't the same as implying
an order of evaluation. Any evaluation ordering that happens to fall
out of an expression syntax is purely a consequence of reality, and has
nothing to do with the rules of C.
The expression i + j + k++ is evaluated on the virtual machine
as (i + j) + k++, not as i + (j + k++). There is potentially
a real difference on some machines.
If the values are initially, say, these:
i = 1;
j = -1;
k = INT_MIN;
then there is a real difference in the abstract machine, too.
Given...
#define CONV (-'0')
...and assuming *p is a digit, consider...
n = *p + CONV + n * 10;
This is a correct form only because there is an implied
ordering of evaluation.
Why? Precedence looks perfectly adequate here.