- tmp/tmpztxdimn3/{from.md → to.md} +189 -89
tmp/tmpztxdimn3/{from.md → to.md}
RENAMED
|
@@ -4,17 +4,17 @@ The semantic descriptions in this International Standard define a
|
|
| 4 |
parameterized nondeterministic abstract machine. This International
|
| 5 |
Standard places no requirement on the structure of conforming
|
| 6 |
implementations. In particular, they need not copy or emulate the
|
| 7 |
structure of the abstract machine. Rather, conforming implementations
|
| 8 |
are required to emulate (only) the observable behavior of the abstract
|
| 9 |
-
machine as explained below.[^
|
| 10 |
|
| 11 |
Certain aspects and operations of the abstract machine are described in
|
| 12 |
this International Standard as implementation-defined (for example,
|
| 13 |
`sizeof(int)`). These constitute the parameters of the abstract machine.
|
| 14 |
Each implementation shall include documentation describing its
|
| 15 |
-
characteristics and behavior in these respects.[^
|
| 16 |
shall define the instance of the abstract machine that corresponds to
|
| 17 |
that implementation (referred to as the “corresponding instance” below).
|
| 18 |
|
| 19 |
Certain other aspects and operations of the abstract machine are
|
| 20 |
described in this International Standard as unspecified (for example,
|
|
@@ -25,56 +25,56 @@ define the nondeterministic aspects of the abstract machine. An instance
|
|
| 25 |
of the abstract machine can thus have more than one possible execution
|
| 26 |
for a given program and a given input.
|
| 27 |
|
| 28 |
Certain other operations are described in this International Standard as
|
| 29 |
undefined (for example, the effect of attempting to modify a `const`
|
| 30 |
-
object).
|
| 31 |
-
|
|
|
|
|
|
|
| 32 |
|
| 33 |
A conforming implementation executing a well-formed program shall
|
| 34 |
produce the same observable behavior as one of the possible executions
|
| 35 |
of the corresponding instance of the abstract machine with the same
|
| 36 |
program and the same input. However, if any such execution contains an
|
| 37 |
undefined operation, this International Standard places no requirement
|
| 38 |
on the implementation executing that program with that input (not even
|
| 39 |
with regard to operations preceding the first undefined operation).
|
| 40 |
|
| 41 |
-
If a signal handler is executed as a result of a call to the `raise`
|
| 42 |
-
function, then the execution of the handler is sequenced after the
|
| 43 |
-
invocation of the `raise` function and before its return. When a signal
|
| 44 |
-
is received for another reason, the execution of the signal handler is
|
| 45 |
-
usually unsequenced with respect to the rest of the program.
|
| 46 |
-
|
| 47 |
An instance of each object with automatic storage duration (
|
| 48 |
[[basic.stc.auto]]) is associated with each entry into its block. Such
|
| 49 |
an object exists and retains its last-stored value during the execution
|
| 50 |
of the block and while the block is suspended (by a call of a function
|
| 51 |
or receipt of a signal).
|
| 52 |
|
| 53 |
The least requirements on a conforming implementation are:
|
| 54 |
|
| 55 |
-
-
|
| 56 |
-
rules of the abstract machine.
|
| 57 |
- At program termination, all data written into files shall be identical
|
| 58 |
to one of the possible results that execution of the program according
|
| 59 |
to the abstract semantics would have produced.
|
| 60 |
- The input and output dynamics of interactive devices shall take place
|
| 61 |
in such a fashion that prompting output is actually delivered before a
|
| 62 |
program waits for input. What constitutes an interactive device is
|
| 63 |
*implementation-defined*.
|
| 64 |
|
| 65 |
These collectively are referred to as the *observable behavior* of the
|
| 66 |
-
program.
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
|
| 69 |
Operators can be regrouped according to the usual mathematical rules
|
| 70 |
-
only where the operators really are associative or commutative.[^
|
| 71 |
example, in the following fragment
|
| 72 |
|
| 73 |
``` cpp
|
| 74 |
int a, b;
|
| 75 |
-
|
| 76 |
a = a + 32760 + b + 5;
|
| 77 |
```
|
| 78 |
|
| 79 |
the expression statement behaves exactly the same as
|
| 80 |
|
|
@@ -111,119 +111,219 @@ since the values for `a` and `b` might have been, respectively, 4 and -8
|
|
| 111 |
or -17 and 12. However on a machine in which overflows do not produce an
|
| 112 |
exception and in which the results of overflows are reversible, the
|
| 113 |
above expression statement can be rewritten by the implementation in any
|
| 114 |
of the above ways because the same result will occur.
|
| 115 |
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 127 |
|
| 128 |
``` cpp
|
| 129 |
struct S {
|
| 130 |
-
S(int i): I(i) { }
|
| 131 |
int& v() { return I; }
|
|
|
|
| 132 |
private:
|
| 133 |
int I;
|
| 134 |
};
|
| 135 |
|
| 136 |
S s1(1); // full-expression is call of S::S(int)
|
| 137 |
-
S s2 = 2; // full-expression is call of S::S(int)
|
| 138 |
-
|
| 139 |
void f() {
|
|
|
|
| 140 |
if (S(3).v()) // full-expression includes lvalue-to-rvalue and
|
| 141 |
// int to bool conversions, performed before
|
| 142 |
// temporary is deleted at end of full-expression
|
| 143 |
{ }
|
|
|
|
|
|
|
|
|
|
| 144 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
```
|
| 146 |
|
| 147 |
-
|
| 148 |
-
subexpressions that are not lexically part of the full-expression. For
|
| 149 |
-
example, subexpressions involved in evaluating default arguments (
|
| 150 |
-
[[dcl.fct.default]]) are considered to be created in the expression that
|
| 151 |
-
calls the function, not the expression that defines the default
|
| 152 |
-
argument.
|
| 153 |
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
|
| 167 |
*Sequenced before* is an asymmetric, transitive, pair-wise relation
|
| 168 |
between evaluations executed by a single thread (
|
| 169 |
[[intro.multithread]]), which induces a partial order among those
|
| 170 |
evaluations. Given any two evaluations *A* and *B*, if *A* is sequenced
|
| 171 |
-
before *B*,
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
Every value computation and side effect associated with a
|
| 180 |
full-expression is sequenced before every value computation and side
|
| 181 |
-
effect associated with the next full-expression to be evaluated.[^
|
| 182 |
|
| 183 |
Except where noted, evaluations of operands of individual operators and
|
| 184 |
-
of subexpressions of individual expressions are unsequenced.
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
evaluations
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
|
| 197 |
``` cpp
|
| 198 |
-
void
|
| 199 |
-
void g(int i, int* v) {
|
| 200 |
-
i = v[i++]; // the behavior is undefined
|
| 201 |
i = 7, i++, i++; // i becomes 9
|
| 202 |
|
| 203 |
-
i = i++ + 1; // the
|
|
|
|
| 204 |
i = i + 1; // the value of i is incremented
|
| 205 |
-
|
| 206 |
-
f(i = -1, i = -1); // the behavior is undefined
|
| 207 |
}
|
| 208 |
```
|
| 209 |
|
|
|
|
|
|
|
| 210 |
When calling a function (whether or not the function is inline), every
|
| 211 |
value computation and side effect associated with any argument
|
| 212 |
expression, or with the postfix expression designating the called
|
| 213 |
function, is sequenced before execution of every expression or statement
|
| 214 |
-
in the body of the called function.
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
|
|
|
|
| 4 |
parameterized nondeterministic abstract machine. This International
|
| 5 |
Standard places no requirement on the structure of conforming
|
| 6 |
implementations. In particular, they need not copy or emulate the
|
| 7 |
structure of the abstract machine. Rather, conforming implementations
|
| 8 |
are required to emulate (only) the observable behavior of the abstract
|
| 9 |
+
machine as explained below.[^6]
|
| 10 |
|
| 11 |
Certain aspects and operations of the abstract machine are described in
|
| 12 |
this International Standard as implementation-defined (for example,
|
| 13 |
`sizeof(int)`). These constitute the parameters of the abstract machine.
|
| 14 |
Each implementation shall include documentation describing its
|
| 15 |
+
characteristics and behavior in these respects.[^7] Such documentation
|
| 16 |
shall define the instance of the abstract machine that corresponds to
|
| 17 |
that implementation (referred to as the “corresponding instance” below).
|
| 18 |
|
| 19 |
Certain other aspects and operations of the abstract machine are
|
| 20 |
described in this International Standard as unspecified (for example,
|
|
|
|
| 25 |
of the abstract machine can thus have more than one possible execution
|
| 26 |
for a given program and a given input.
|
| 27 |
|
| 28 |
Certain other operations are described in this International Standard as
|
| 29 |
undefined (for example, the effect of attempting to modify a `const`
|
| 30 |
+
object).
|
| 31 |
+
|
| 32 |
+
[*Note 1*: This International Standard imposes no requirements on the
|
| 33 |
+
behavior of programs that contain undefined behavior. — *end note*]
|
| 34 |
|
| 35 |
A conforming implementation executing a well-formed program shall
|
| 36 |
produce the same observable behavior as one of the possible executions
|
| 37 |
of the corresponding instance of the abstract machine with the same
|
| 38 |
program and the same input. However, if any such execution contains an
|
| 39 |
undefined operation, this International Standard places no requirement
|
| 40 |
on the implementation executing that program with that input (not even
|
| 41 |
with regard to operations preceding the first undefined operation).
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
An instance of each object with automatic storage duration (
|
| 44 |
[[basic.stc.auto]]) is associated with each entry into its block. Such
|
| 45 |
an object exists and retains its last-stored value during the execution
|
| 46 |
of the block and while the block is suspended (by a call of a function
|
| 47 |
or receipt of a signal).
|
| 48 |
|
| 49 |
The least requirements on a conforming implementation are:
|
| 50 |
|
| 51 |
+
- Accesses through volatile glvalues are evaluated strictly according to
|
| 52 |
+
the rules of the abstract machine.
|
| 53 |
- At program termination, all data written into files shall be identical
|
| 54 |
to one of the possible results that execution of the program according
|
| 55 |
to the abstract semantics would have produced.
|
| 56 |
- The input and output dynamics of interactive devices shall take place
|
| 57 |
in such a fashion that prompting output is actually delivered before a
|
| 58 |
program waits for input. What constitutes an interactive device is
|
| 59 |
*implementation-defined*.
|
| 60 |
|
| 61 |
These collectively are referred to as the *observable behavior* of the
|
| 62 |
+
program.
|
| 63 |
+
|
| 64 |
+
[*Note 2*: More stringent correspondences between abstract and actual
|
| 65 |
+
semantics may be defined by each implementation. — *end note*]
|
| 66 |
+
|
| 67 |
+
[*Note 3*:
|
| 68 |
|
| 69 |
Operators can be regrouped according to the usual mathematical rules
|
| 70 |
+
only where the operators really are associative or commutative.[^8] For
|
| 71 |
example, in the following fragment
|
| 72 |
|
| 73 |
``` cpp
|
| 74 |
int a, b;
|
| 75 |
+
...
|
| 76 |
a = a + 32760 + b + 5;
|
| 77 |
```
|
| 78 |
|
| 79 |
the expression statement behaves exactly the same as
|
| 80 |
|
|
|
|
| 111 |
or -17 and 12. However on a machine in which overflows do not produce an
|
| 112 |
exception and in which the results of overflows are reversible, the
|
| 113 |
above expression statement can be rewritten by the implementation in any
|
| 114 |
of the above ways because the same result will occur.
|
| 115 |
|
| 116 |
+
— *end note*]
|
| 117 |
+
|
| 118 |
+
A *constituent expression* is defined as follows:
|
| 119 |
+
|
| 120 |
+
- The constituent expression of an expression is that expression.
|
| 121 |
+
- The constituent expressions of a *braced-init-list* or of a (possibly
|
| 122 |
+
parenthesized) *expression-list* are the constituent expressions of
|
| 123 |
+
the elements of the respective list.
|
| 124 |
+
- The constituent expressions of a *brace-or-equal-initializer* of the
|
| 125 |
+
form `=` *initializer-clause* are the constituent expressions of the
|
| 126 |
+
*initializer-clause*.
|
| 127 |
+
|
| 128 |
+
[*Example 1*:
|
| 129 |
+
|
| 130 |
+
``` cpp
|
| 131 |
+
struct A { int x; };
|
| 132 |
+
struct B { int y; struct A a; };
|
| 133 |
+
B b = { 5, { 1+1 } };
|
| 134 |
+
```
|
| 135 |
+
|
| 136 |
+
The constituent expressions of the *initializer* used for the
|
| 137 |
+
initialization of `b` are `5` and `1+1`.
|
| 138 |
+
|
| 139 |
+
— *end example*]
|
| 140 |
+
|
| 141 |
+
The *immediate subexpressions* of an expression `e` are
|
| 142 |
+
|
| 143 |
+
- the constituent expressions of `e`’s operands (Clause [[expr]]),
|
| 144 |
+
- any function call that `e` implicitly invokes,
|
| 145 |
+
- if `e` is a *lambda-expression* ([[expr.prim.lambda]]), the
|
| 146 |
+
initialization of the entities captured by copy and the constituent
|
| 147 |
+
expressions of the *initializer* of the *init-capture*s,
|
| 148 |
+
- if `e` is a function call ([[expr.call]]) or implicitly invokes a
|
| 149 |
+
function, the constituent expressions of each default argument (
|
| 150 |
+
[[dcl.fct.default]]) used in the call, or
|
| 151 |
+
- if `e` creates an aggregate object ([[dcl.init.aggr]]), the
|
| 152 |
+
constituent expressions of each default member initializer (
|
| 153 |
+
[[class.mem]]) used in the initialization.
|
| 154 |
+
|
| 155 |
+
A *subexpression* of an expression `e` is an immediate subexpression of
|
| 156 |
+
`e` or a subexpression of an immediate subexpression of `e`.
|
| 157 |
+
|
| 158 |
+
[*Note 4*: Expressions appearing in the *compound-statement* of a
|
| 159 |
+
*lambda-expression* are not subexpressions of the
|
| 160 |
+
*lambda-expression*. — *end note*]
|
| 161 |
+
|
| 162 |
+
A *full-expression* is
|
| 163 |
+
|
| 164 |
+
- an unevaluated operand (Clause [[expr]]),
|
| 165 |
+
- a *constant-expression* ([[expr.const]]),
|
| 166 |
+
- an *init-declarator* (Clause [[dcl.decl]]) or a *mem-initializer* (
|
| 167 |
+
[[class.base.init]]), including the constituent expressions of the
|
| 168 |
+
initializer,
|
| 169 |
+
- an invocation of a destructor generated at the end of the lifetime of
|
| 170 |
+
an object other than a temporary object ([[class.temporary]]), or
|
| 171 |
+
- an expression that is not a subexpression of another expression and
|
| 172 |
+
that is not otherwise part of a full-expression.
|
| 173 |
+
|
| 174 |
+
If a language construct is defined to produce an implicit call of a
|
| 175 |
+
function, a use of the language construct is considered to be an
|
| 176 |
+
expression for the purposes of this definition. Conversions applied to
|
| 177 |
+
the result of an expression in order to satisfy the requirements of the
|
| 178 |
+
language construct in which the expression appears are also considered
|
| 179 |
+
to be part of the full-expression. For an initializer, performing the
|
| 180 |
+
initialization of the entity (including evaluating default member
|
| 181 |
+
initializers of an aggregate) is also considered part of the
|
| 182 |
+
full-expression.
|
| 183 |
+
|
| 184 |
+
[*Example 2*:
|
| 185 |
|
| 186 |
``` cpp
|
| 187 |
struct S {
|
| 188 |
+
S(int i): I(i) { } // full-expression is initialization of I
|
| 189 |
int& v() { return I; }
|
| 190 |
+
~S() noexcept(false) { }
|
| 191 |
private:
|
| 192 |
int I;
|
| 193 |
};
|
| 194 |
|
| 195 |
S s1(1); // full-expression is call of S::S(int)
|
|
|
|
|
|
|
| 196 |
void f() {
|
| 197 |
+
S s2 = 2; // full-expression is call of S::S(int)
|
| 198 |
if (S(3).v()) // full-expression includes lvalue-to-rvalue and
|
| 199 |
// int to bool conversions, performed before
|
| 200 |
// temporary is deleted at end of full-expression
|
| 201 |
{ }
|
| 202 |
+
bool b = noexcept(S()); // exception specification of destructor of S
|
| 203 |
+
// considered for noexcept
|
| 204 |
+
// full-expression is destruction of s2 at end of block
|
| 205 |
}
|
| 206 |
+
struct B {
|
| 207 |
+
B(S = S(0));
|
| 208 |
+
};
|
| 209 |
+
B b[2] = { B(), B() }; // full-expression is the entire initialization
|
| 210 |
+
// including the destruction of temporaries
|
| 211 |
```
|
| 212 |
|
| 213 |
+
— *end example*]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
+
[*Note 5*: The evaluation of a full-expression can include the
|
| 216 |
+
evaluation of subexpressions that are not lexically part of the
|
| 217 |
+
full-expression. For example, subexpressions involved in evaluating
|
| 218 |
+
default arguments ([[dcl.fct.default]]) are considered to be created in
|
| 219 |
+
the expression that calls the function, not the expression that defines
|
| 220 |
+
the default argument. — *end note*]
|
| 221 |
+
|
| 222 |
+
Reading an object designated by a `volatile` glvalue ([[basic.lval]]),
|
| 223 |
+
modifying an object, calling a library I/O function, or calling a
|
| 224 |
+
function that does any of those operations are all *side effects*, which
|
| 225 |
+
are changes in the state of the execution environment. *Evaluation* of
|
| 226 |
+
an expression (or a subexpression) in general includes both value
|
| 227 |
+
computations (including determining the identity of an object for
|
| 228 |
+
glvalue evaluation and fetching a value previously assigned to an object
|
| 229 |
+
for prvalue evaluation) and initiation of side effects. When a call to a
|
| 230 |
+
library I/O function returns or an access through a volatile glvalue is
|
| 231 |
+
evaluated the side effect is considered complete, even though some
|
| 232 |
+
external actions implied by the call (such as the I/O itself) or by the
|
| 233 |
+
`volatile` access may not have completed yet.
|
| 234 |
|
| 235 |
*Sequenced before* is an asymmetric, transitive, pair-wise relation
|
| 236 |
between evaluations executed by a single thread (
|
| 237 |
[[intro.multithread]]), which induces a partial order among those
|
| 238 |
evaluations. Given any two evaluations *A* and *B*, if *A* is sequenced
|
| 239 |
+
before *B* (or, equivalently, *B* is *sequenced after* *A*), then the
|
| 240 |
+
execution of *A* shall precede the execution of *B*. If *A* is not
|
| 241 |
+
sequenced before *B* and *B* is not sequenced before *A*, then *A* and
|
| 242 |
+
*B* are *unsequenced*.
|
| 243 |
+
|
| 244 |
+
[*Note 6*: The execution of unsequenced evaluations can
|
| 245 |
+
overlap. — *end note*]
|
| 246 |
+
|
| 247 |
+
Evaluations *A* and *B* are *indeterminately sequenced* when either *A*
|
| 248 |
+
is sequenced before *B* or *B* is sequenced before *A*, but it is
|
| 249 |
+
unspecified which.
|
| 250 |
+
|
| 251 |
+
[*Note 7*: Indeterminately sequenced evaluations cannot overlap, but
|
| 252 |
+
either could be executed first. — *end note*]
|
| 253 |
+
|
| 254 |
+
An expression *X* is said to be sequenced before an expression *Y* if
|
| 255 |
+
every value computation and every side effect associated with the
|
| 256 |
+
expression *X* is sequenced before every value computation and every
|
| 257 |
+
side effect associated with the expression *Y*.
|
| 258 |
|
| 259 |
Every value computation and side effect associated with a
|
| 260 |
full-expression is sequenced before every value computation and side
|
| 261 |
+
effect associated with the next full-expression to be evaluated.[^9]
|
| 262 |
|
| 263 |
Except where noted, evaluations of operands of individual operators and
|
| 264 |
+
of subexpressions of individual expressions are unsequenced.
|
| 265 |
+
|
| 266 |
+
[*Note 8*: In an expression that is evaluated more than once during the
|
| 267 |
+
execution of a program, unsequenced and indeterminately sequenced
|
| 268 |
+
evaluations of its subexpressions need not be performed consistently in
|
| 269 |
+
different evaluations. — *end note*]
|
| 270 |
+
|
| 271 |
+
The value computations of the operands of an operator are sequenced
|
| 272 |
+
before the value computation of the result of the operator. If a side
|
| 273 |
+
effect on a memory location ([[intro.memory]]) is unsequenced relative
|
| 274 |
+
to either another side effect on the same memory location or a value
|
| 275 |
+
computation using the value of any object in the same memory location,
|
| 276 |
+
and they are not potentially concurrent ([[intro.multithread]]), the
|
| 277 |
+
behavior is undefined.
|
| 278 |
+
|
| 279 |
+
[*Note 9*: The next section imposes similar, but more complex
|
| 280 |
+
restrictions on potentially concurrent computations. — *end note*]
|
| 281 |
+
|
| 282 |
+
[*Example 3*:
|
| 283 |
|
| 284 |
``` cpp
|
| 285 |
+
void g(int i) {
|
|
|
|
|
|
|
| 286 |
i = 7, i++, i++; // i becomes 9
|
| 287 |
|
| 288 |
+
i = i++ + 1; // the value of i is incremented
|
| 289 |
+
i = i++ + i; // the behavior is undefined
|
| 290 |
i = i + 1; // the value of i is incremented
|
|
|
|
|
|
|
| 291 |
}
|
| 292 |
```
|
| 293 |
|
| 294 |
+
— *end example*]
|
| 295 |
+
|
| 296 |
When calling a function (whether or not the function is inline), every
|
| 297 |
value computation and side effect associated with any argument
|
| 298 |
expression, or with the postfix expression designating the called
|
| 299 |
function, is sequenced before execution of every expression or statement
|
| 300 |
+
in the body of the called function. For each function invocation *F*,
|
| 301 |
+
for every evaluation *A* that occurs within *F* and every evaluation *B*
|
| 302 |
+
that does not occur within *F* but is evaluated on the same thread and
|
| 303 |
+
as part of the same signal handler (if any), either *A* is sequenced
|
| 304 |
+
before *B* or *B* is sequenced before *A*.[^10]
|
| 305 |
+
|
| 306 |
+
[*Note 10*: If *A* and *B* would not otherwise be sequenced then they
|
| 307 |
+
are indeterminately sequenced. — *end note*]
|
| 308 |
+
|
| 309 |
+
Several contexts in C++cause evaluation of a function call, even though
|
| 310 |
+
no corresponding function call syntax appears in the translation unit.
|
| 311 |
+
|
| 312 |
+
[*Example 4*: Evaluation of a *new-expression* invokes one or more
|
| 313 |
+
allocation and constructor functions; see [[expr.new]]. For another
|
| 314 |
+
example, invocation of a conversion function ([[class.conv.fct]]) can
|
| 315 |
+
arise in contexts in which no function call syntax
|
| 316 |
+
appears. — *end example*]
|
| 317 |
+
|
| 318 |
+
The sequencing constraints on the execution of the called function (as
|
| 319 |
+
described above) are features of the function calls as evaluated,
|
| 320 |
+
whatever the syntax of the expression that calls the function might be.
|
| 321 |
+
|
| 322 |
+
If a signal handler is executed as a result of a call to the
|
| 323 |
+
`std::raise` function, then the execution of the handler is sequenced
|
| 324 |
+
after the invocation of the `std::raise` function and before its return.
|
| 325 |
+
|
| 326 |
+
[*Note 11*: When a signal is received for another reason, the execution
|
| 327 |
+
of the signal handler is usually unsequenced with respect to the rest of
|
| 328 |
+
the program. — *end note*]
|
| 329 |
|