The section of the ANSI/ISO C++ Standard
dealing with program execution (1.9) also introduces sequence points.
C++ sequence points happen at the same places as C sequence points:
- after a full-expression (i.e. an expression that is not a sub expression of another expression, or more succnctly stated, at every semicolon),
- just after all of the arguments to a function call have been evaluated, and just before the function is called,
- after the left operand of certain operators (&&, ||, ?:, ,) has been evaulated,
but adds a couple of other places:
- Just *after* the return value from the function has been copied (possibly by a copy constructor), and just before expressions outside the function (such as a destructor call for some temporary value) are evaulated,
- Just after a declaration invoking a constructor call with (),
t_foo foo (bar, baz);
- After each initializer at the beginning of a constructor definition.
t_foo::t_foo (/*here*/t_bar ibar, t_baz ibaz): bar (ibar)/*here*/, baz (ibaz)/*here*/
Notice that all of the above conditions could be interpreted as special cases of the sequence point conditions in C, but are a bit more precise because of things C++ adds.
Finally, the section of the C++ Standard dealing with expression
s (5.4) also makes the prohibition against modifying the same lvalue twice without an intervening sequence point.
Source: International Standard ISO-IEC 14882, Programming Languages
-- C++, published by the American National Standards Institute, ©
1998 Information Technology Industry Council.