su**************@yahoo.com, India said:
Consider
a[i] = ++i;
This will invoke undefined behaviour because the order of evaluation
of operands of an operator is not specified.
I suppose that, if the order of evaluation were *completely* defined,
the code would be okay, and it isn't so it isn't, and therefore, in a
way, you are right. But if you want the Chapter and Verse, it goes like
this:
"Between the previous and next sequence point an object shall have its
stored value modified at most once by the evaluation of an expression.
Furthermore, the prior value shall be accessed only to determine the
value to be stored." (That's from 3.3.)
So the code violates a "shall" requirement that, as it happens, is not
part of a constraint. And within the definition of "undefined behavior"
in 1.6, we find:
"If a ``shall'' or ``shall not'' requirement that appears outside of a
constraint is violated, the behavior is undefined."
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.