order of evaluation

utzoo!watmath!watcgl!dmmartindale utzoo!watmath!watcgl!dmmartindale
Sat Feb 26 14:15:50 AEST 1983

The problem here is due to a misunderstanding.  In some languages, the
statement "a[i++] = i++;" would be called an "assignment statement",
with the subscript considered one expression, the stuff on the right hand
of the assignment operator another expression, and the assignment operator
itself not part of any expression.  In C, however, the assignment operator
is just like any other expression operator, and the whole thing above is
a single expression.  (Note that most statements in C are simply an expression
followed by a semicolon.)  So the compiler is justified in doing all the
pre-increments before and all the post-increments after the assignment itself.

More information about the Comp.lang.c mailing list