On 3 Jun 2007 at 15:02, davis wrote:
I'm missing the ambiguity, although hard rules
for post inc were
fuzzy back then. (70's-80's)
In Sroustrup, x++ is stated to be evaluated as:
t = x;
x += 1;
t;
where t signifies a temporary. In other words, the ++ increment is
performed at its occurrence within the statement, not after the
remainder of the statement has been evaluated. So, in n=1; a[n++] =
n++; all we know is that n will be incremented to 2 then to 3. But
which side of the assignment gets incremented first? That's
unspecified.
A similar conundrum is:
int f( int, int, int);
n=1;
f(++n, ++n, ++n);
What gets passed to f? Why?
Cheers,
Chuck