The problem is that exactly when the increment occurs is not specified. We only know that the increment occurs at some point AFTER the initial value of i is loaded on the RHS. So there are two possibilities:
The original value of i is stored in a temporary, then i is incremented, then the temporary is stored in i. The result is no change in the value whatsoever.
The original value of i is stored in a temporary, then the temporary is stored in i, then i is incremented. The result is that i is incremented.
I believe this is an example of unspecified behavior, as opposed to undefined.
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}
No, I think that the behaviour is undefined. Consider: we know that between the previous and next sequence point, a value will be assigned to i, thus i will be modified. We also know that "side effect of updating the stored value of the operand shall occur between the previous and the next sequence point". Therefore, i is modified twice between consecutive sequence points, resulting in undefined behaviour.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)