g(). In C and C++, the
+operator is not a sequence point, and therefore in the expression
f()+g()it is possible that either
g()will be executed first. The comma operator is a sequence point, and therefore in the code
f(),g()the order of evaluation is defined (i.e., first
f()is called, and then
g()is called). The type and value of the whole expression are those of
g(); the value of
Sequence points also come into play when the same variable is modified more than once. An often-cited example is the expression
i=i++, which both assigns
i to itself and increments
i; what is the final value of
i? Language definitions might specify one of the possible behaviors or simply say the behavior is undefined. In C and C++, evaluating such an expression yields undefined behavior.
*p++ != 0 && *q++ != 0, all side effects of the sub-expression
*p++ != 0are completed before any attempt to access
a = (*p++) ? (*p++) : 0there is a sequence point after the first
*p++, meaning it has already been incremented by the time the second instance is executed.
a=b;), return statements, the controlling expressions of
whilestatements, and all three expressions in a
f(i++) + g(j++) + h(k++),
fis called with a parameter of the original value of
iis incremented before entering the body of
kare updated before entering
hrespectively. However, it is not specified in which order
h()are executed, nor in which order
kare incremented. The values of
kin the body of
fare therefore undefined. Note that a function call
f(a,b,c)is not a use of the comma operator and the order of evaluation for
5in the declaration
int a = 5;.
PENNEY, BENNETT GO OUT TOGETHER? THE UW SENIOR AND ASSISTANT COACH WHO RECRUITED HIM EACH MIGHT BE ELSEWHERE NEXT YEAR.(SPORTS)
Mar 28, 2003; Byline: Tom Mulhern Wisconsin State Journal MINNEAPOLIS -- Kirk Penney and Tony Bennett officially arrived together at the...