On Mon, 16 Dec 2002, Kevin P. Fleming wrote:
> Not to beat a dead horse there, but I think the operative word here is
> "evaluation". The ++ and -- operators are not part of the "evaluation" of the
> condition, at least not in the strictest sense of that word.
I think you will find that they are. The value of the condition is the
value of the expression, and these operators are part of the expression.
The value of ++x is the incremented value of the variable x. It has a
value; therefore, there is an "evaluation". A quote from the standard:
"The result is the new value of the operand after incrementation. The
expression ++E is equivalent to (E+=1)."
> I could be way off base here, in which case never mind...
I'm afraid I'm sure that you are way off base. Here's a longer quote
from the Standard:
"Unlike the bitwise binary & operator, the && operator guarantees
left-to-right evaluation; there is a sequence point after the evaluation
of the first operand. If the first operand compares equal to 0, the
second operand is not evaluated."
... and in the discussion of the ++ operator: "The side effect of updating
the stored value of the operand shall occur between the previous and the next
sequence points."
> I'd bet it could work either way legally.
I beg to differ, I'm afraid.
Regards,
Philip
--
Philip Hazel University of Cambridge Computing Service,
ph10@??? Cambridge, England. Phone: +44 1223 334714.