TITLE: Sequence points and expression side effects PROBLEM: andrzej@cs.UAlberta.CA (Semeniuk Andrzej) int j = 0; (++j)++; cout << "j = " << j << "\n"; and obtained the following output: j = 3 I expected a 2. RESPONSE: mayoff@sylvester.cc.utexas.edu (rob) I suggest that the parenthesis guarantee that the inner expression must be executed before its containing expression. You can't compute (a+b)+c without first computing (a+b), right? So to evaluate (++j)++, you must first compute (++j), which includes executing the side effect of storing the new value of j. RESPONSE: jimad@microsoft.com (Jim Adcock), Microsoft Corporation, 9 Jul 93 No, this last sentence is in error. ARM states that the value of (++j) is an lvalue equal to (j+1). ARM doesn't state that the lvalue is a reference to j. Thus while (++j) must return a value (j+1), the point in time that j itself is incremented remains undefined [excepting that it must happen between sequence points] IE the compiler could implement this preincrement part as if: j = j+1; return j; implement other parts of the expression or it could implement it as if: return (temp = j+1); implement other parts of the expression j = temp; or the compiler could do whatever else it might choose, since the overall expression is an unconstrained error [my claim from the ANSI C base doc] Note that there *are* some expressions where multiple side effects are allowed, such as ARM alludes to. The following expression is such an example: j++, j++, j++; Since each comma in the expression represents a sequence point, the side effect must be completed by each comma, and thus this expression is legal and well-defined. Legal both by ARM and X3.159-1989.