tmp/tmp6_6bhz9b/{from.md → to.md}
RENAMED
|
@@ -9,16 +9,16 @@ phases of initiation, initialization occurs as follows.
|
|
| 9 |
with static or thread storage duration is constant-initialized
|
| 10 |
[[expr.const]]. If constant initialization is not performed, a variable
|
| 11 |
with static storage duration [[basic.stc.static]] or thread storage
|
| 12 |
duration [[basic.stc.thread]] is zero-initialized [[dcl.init]].
|
| 13 |
Together, zero-initialization and constant initialization are called
|
| 14 |
-
*static initialization*; all other initialization is
|
| 15 |
-
initialization*. All static initialization strongly happens
|
| 16 |
-
[[intro.races]] any dynamic initialization.
|
| 17 |
|
| 18 |
-
[*Note 1*: The dynamic initialization of non-
|
| 19 |
-
described in [[basic.start.dynamic]]; that of
|
| 20 |
described in [[stmt.dcl]]. — *end note*]
|
| 21 |
|
| 22 |
An implementation is permitted to perform the initialization of a
|
| 23 |
variable with static or thread storage duration as a static
|
| 24 |
initialization even if such initialization is not required to be done
|
|
@@ -33,23 +33,23 @@ statically, provided that
|
|
| 33 |
statically were initialized dynamically.
|
| 34 |
|
| 35 |
[*Note 2*:
|
| 36 |
|
| 37 |
As a consequence, if the initialization of an object `obj1` refers to an
|
| 38 |
-
object `obj2`
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
|
| 44 |
``` cpp
|
| 45 |
inline double fd() { return 1.0; }
|
| 46 |
extern double d1;
|
| 47 |
double d2 = d1; // unspecified:
|
| 48 |
-
//
|
| 49 |
// dynamically initialized to 0.0 if d1 is
|
| 50 |
// dynamically initialized, or 1.0 otherwise
|
| 51 |
-
double d1 = fd(); //
|
| 52 |
```
|
| 53 |
|
| 54 |
— *end note*]
|
| 55 |
|
|
|
|
| 9 |
with static or thread storage duration is constant-initialized
|
| 10 |
[[expr.const]]. If constant initialization is not performed, a variable
|
| 11 |
with static storage duration [[basic.stc.static]] or thread storage
|
| 12 |
duration [[basic.stc.thread]] is zero-initialized [[dcl.init]].
|
| 13 |
Together, zero-initialization and constant initialization are called
|
| 14 |
+
*static initialization*; all other initialization is
|
| 15 |
+
*dynamic initialization*. All static initialization strongly happens
|
| 16 |
+
before [[intro.races]] any dynamic initialization.
|
| 17 |
|
| 18 |
+
[*Note 1*: The dynamic initialization of non-block variables is
|
| 19 |
+
described in [[basic.start.dynamic]]; that of static block variables is
|
| 20 |
described in [[stmt.dcl]]. — *end note*]
|
| 21 |
|
| 22 |
An implementation is permitted to perform the initialization of a
|
| 23 |
variable with static or thread storage duration as a static
|
| 24 |
initialization even if such initialization is not required to be done
|
|
|
|
| 33 |
statically were initialized dynamically.
|
| 34 |
|
| 35 |
[*Note 2*:
|
| 36 |
|
| 37 |
As a consequence, if the initialization of an object `obj1` refers to an
|
| 38 |
+
object `obj2` potentially requiring dynamic initialization and defined
|
| 39 |
+
later in the same translation unit, it is unspecified whether the value
|
| 40 |
+
of `obj2` used will be the value of the fully initialized `obj2`
|
| 41 |
+
(because `obj2` was statically initialized) or will be the value of
|
| 42 |
+
`obj2` merely zero-initialized. For example,
|
| 43 |
|
| 44 |
``` cpp
|
| 45 |
inline double fd() { return 1.0; }
|
| 46 |
extern double d1;
|
| 47 |
double d2 = d1; // unspecified:
|
| 48 |
+
// either statically initialized to 0.0 or
|
| 49 |
// dynamically initialized to 0.0 if d1 is
|
| 50 |
// dynamically initialized, or 1.0 otherwise
|
| 51 |
+
double d1 = fd(); // either initialized statically or dynamically to 1.0
|
| 52 |
```
|
| 53 |
|
| 54 |
— *end note*]
|
| 55 |
|