Jack said:
[snip]
I think, this is *not* a matter of sequence points. The expression is
equivalent to:
operator<< (
operator<< (
operator<< (
operator<< ( std::cout, x ),
" "
),
x++
),
std::endl;
);
and the various function calls provide sufficiently many sequence points.
The results are implementation defined because the evaluation order of
the parameters passed in a function call is implementation defined.
It really still is sequence points. There is no guarantee in the
original expression, or in the expression as you have rewritten it,
that any of the sequence points occurs in between the two accesses of
'x'. The results are undefined for that reason.
Thanks for the correction,
I think, I see what you mean. Just to check my understanding: the following
is implementation defined behavior, but not undefined
int post_inc( int & x ) {
int dummy = x;
++x;
return( dummy );
}
operator<< (
operator<< (
operator<< (
operator<< ( std::cout, x ),
" "
),
post_inc( x )
),
std::endl;
);
The reason would be that in the evaluation of sub-expressions one of the
calls operator<<( std::cout, x ) and post_inc( x ) comes first.
Whichever comes first has a sequence point upon return, which separates the
two accesses to x. The reason this does not apply to the original
expression is that x++ is not a function call. Is that correct?
Thanks again
Kai-Uwe Bux