![](https://csdnimg.cn/release/download_crawler_static/10166697/bg14.jpg)
© ISO/IEC N4700
struct B {
B(S = S(0));
};
B b[2] = { B(), B() }; // full-expression is the entire initialization
// including the destruction of temporaries
— end example ]
13
[ Note: The evaluation of a full-expression can include the evaluation of subexpressions that are not lexically
part of the full-expression. For example, subexpressions involved in evaluating default arguments (11.3.6) are
considered to be created in the expression that calls the function, not the expression that defines the default
argument. — end note ]
14
Reading an object designated by a
volatile
glvalue (6.10), modifying an object, calling a library I/O
function, or calling a function that does any of those operations are all side effects, which are changes in the
state of the execution environment. Evaluation of an expression (or a subexpression) in general includes both
value computations (including determining the identity of an object for glvalue evaluation and fetching a
value previously assigned to an object for prvalue evaluation) and initiation of side effects. When a call to a
library I/O function returns or an access through a volatile glvalue is evaluated the side effect is considered
complete, even though some external actions implied by the call (such as the I/O itself) or by the
volatile
access may not have completed yet.
15
Sequenced before is an asymmetric, transitive, pair-wise relation between evaluations executed by a single
thread (4.7), which induces a partial order among those evaluations. Given any two evaluations A and B,
if A is sequenced before B (or, equivalently, B is sequenced after A), then the execution of A shall precede
the execution of B. If A is not sequenced before B and B is not sequenced before A, then A and B are
unsequenced. [ Note: The execution of unsequenced evaluations can overlap. — end note ] Evaluations
A and B are indeterminately sequenced when either A is sequenced before B or B is sequenced before A,
but it is unspecified which. [ Note: Indeterminately sequenced evaluations cannot overlap, but either could
be executed first. — end note ] An expression X is said to be sequenced before an expression Y if every
value computation and every side effect associated with the expression X is sequenced before every value
computation and every side effect associated with the expression Y.
16
Every value computation and side effect associated with a full-expression is sequenced before every value
computation and side effect associated with the next full-expression to be evaluated.
9
17
Except where noted, evaluations of operands of individual operators and of subexpressions of individual
expressions are unsequenced. [ Note: In an expression that is evaluated more than once during the execution
of a program, unsequenced and indeterminately sequenced evaluations of its subexpressions need not be
performed consistently in different evaluations. — end note ] The value computations of the operands of
an operator are sequenced before the value computation of the result of the operator. If a side effect on a
memory location (4.4) is unsequenced relative to either another side effect on the same memory location or a
value computation using the value of any object in the same memory location, and they are not potentially
concurrent (4.7), the behavior is undefined. [ Note: The next section imposes similar, but more complex
restrictions on potentially concurrent computations. — end note ]
[ Example:
void g(int i) {
i = 7, i++, i++; // i becomes 9
i = i++ + 1; // the value of i is incremented
i = i++ + i; // the behavior is undefined
i = i + 1; // the value of i is incremented
}
— end example ]
18
When calling a function (whether or not the function is inline), every value computation and side effect
associated with any argument expression, or with the postfix expression designating the called function, is
sequenced before execution of every expression or statement in the body of the called function. For each
function invocation F, for every evaluation A that occurs within F and every evaluation B that does not
occur within F but is evaluated on the same thread and as part of the same signal handler (if any), either A is
9)
As specified in 15.2, after a full-expression is evaluated, a sequence of zero or more invocations of destructor functions for
temporary objects takes place, usually in reverse order of the construction of each temporary object.
§ 4.6 12