The following expressions are unsequenced:
a + b;
a - b;
a * b;
a / b;
a % b;
a & b;
a | b;
In the above examples, the expression a
may be evaluated before or after the expression b
, b
may be evaluated before a
, or they may even be intermixed if they correspond to several instructions.
A similar rule holds for function calls:
f(a, b);
Here not only a
and b
are unsequenced (i.e. the ,
operator in a function call does not produce a sequence point) but also f
, the expression that determines the function that is to be called.
Side effects may be applied immediately after evaluation or deferred until a later point.
Expressions like
x++ & x++;
f(x++, x++); /* the ',' in a function call is *not* the same as the comma operator */
x++ * x++;
a[i] = i++;
or
x++ & x;
f(x++, x);
x++ * x;
a[i++] = i;
will yield undefined behavior because
1 Any changes in the state of the execution environment.