"The order of evaluation of subexpressions within an expression is
undefined." - Bjarne Stroustrup, "The C++ Programming Language",
Special Edition, January 2000.
Mr Stroustrup appears to disagree with Mr Stroustrup. Here in
comp.lang.c we cannot possibly countenance judging between the opinions
of these two C++ masters, so I must refer you to comp.lang.c++, where
you may well find that either Mr Stroustrup or Mr Stroustrup will be
able to clarify.
(To be belatedly fair to Bjarne Stroustrup, something rather important
and dramatic happened to C++ between 1991 and 1998.)
Indeed, but the standardization only clarified that part of the text,
rather than changing the rules. The full quote is/was
The order of evaluation of subexpressions is determined by the
precedence and grouping of
the operators. The usual mathematical rules for associativity and
commutativity of operators
may be applied only where the operators really are associative and
commutative. Except
where noted, the order of evaluation of operands of individual
operators is undefined. In
particular, if a value is modified twice in an expression, the
result of the expression is
undefined except where an ordering is guaranteed by the operators
involved. For example:
i = v [i++; ] // the value of 'i8 is undefined
i-7, i++i+,+ ; // 'it becomes 9
I was (I think and rather unsuccessfully) trying to distinguish
between the effect of the grouping and precedence rules (as in (x*y)/z
v.s. x*(y/z)) on the meaning of an expression and the order of
evaluations rules.
Except where noted, the order of evaluation of operands of
individual operators is undefined.
Makes clear that there was no C/C++ incompatibility in this case
("except where noted" refers to the text for ||, &&, and comma). I
don't recall this as a significant problem for users and none for
implementers.
It is always hazardous to cut part of a paragraph out of context.
-- Bjarne Stroustrup;
http://www.research.att.com/~bs