From Jason Turner

[basic.start.dynamic]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpcx7hm_w8/{from.md → to.md} +25 -15
tmp/tmpcx7hm_w8/{from.md → to.md} RENAMED
@@ -1,6 +1,6 @@
1
- ### Dynamic initialization of non-local variables <a id="basic.start.dynamic">[[basic.start.dynamic]]</a>
2
 
3
  Dynamic initialization of a non-local variable with static storage
4
  duration is unordered if the variable is an implicitly or explicitly
5
  instantiated specialization, is partially-ordered if the variable is an
6
  inline variable that is not an implicitly or explicitly instantiated
@@ -8,23 +8,33 @@ specialization, and otherwise is ordered.
8
 
9
  [*Note 1*: An explicitly specialized non-inline static data member or
10
  variable template specialization has ordered
11
  initialization. — *end note*]
12
 
 
 
 
 
 
 
 
 
13
  Dynamic initialization of non-local variables `V` and `W` with static
14
  storage duration are ordered as follows:
15
 
16
- - If `V` and `W` have ordered initialization and `V` is defined before
17
- `W` within a single translation unit, the initialization of `V` is
18
- sequenced before the initialization of `W`.
19
- - If `V` has partially-ordered initialization, `W` does not have
20
- unordered initialization, and `V` is defined before `W` in every
21
- translation unit in which `W` is defined, then
22
- - if the program starts a thread ([[intro.multithread]]) other than
23
- the main thread ([[basic.start.main]]), the initialization of `V`
24
- strongly happens before the initialization of `W`;
25
- - otherwise, the initialization of `V` is sequenced before the
 
 
26
  initialization of `W`.
27
  - Otherwise, if the program starts a thread other than the main thread
28
  before either `V` or `W` is initialized, it is unspecified in which
29
  threads the initializations of `V` and `W` occur; the initializations
30
  are unsequenced if they occur in the same thread.
@@ -32,20 +42,20 @@ storage duration are ordered as follows:
32
  sequenced.
33
 
34
  [*Note 2*: This definition permits initialization of a sequence of
35
  ordered variables concurrently with another sequence. — *end note*]
36
 
37
- A *non-initialization odr-use* is an odr-use ([[basic.def.odr]]) not
38
  caused directly or indirectly by the initialization of a non-local
39
  static or thread storage duration variable.
40
 
41
  It is *implementation-defined* whether the dynamic initialization of a
42
  non-local non-inline variable with static storage duration is sequenced
43
  before the first statement of `main` or is deferred. If it is deferred,
44
  it strongly happens before any non-initialization odr-use of any
45
  non-inline function or non-inline variable defined in the same
46
- translation unit as the variable to be initialized. [^11] It is
47
  *implementation-defined* in which threads and at which points in the
48
  program such deferred dynamic initialization occurs.
49
 
50
  [*Note 3*: Such points should be chosen in a way that allows the
51
  programmer to avoid deadlocks. — *end note*]
@@ -104,8 +114,8 @@ odr-use by *t* of any non-inline variable with thread storage duration
104
  defined in the same translation unit as the variable to be initialized.
105
  It is *implementation-defined* in which threads and at which points in
106
  the program such deferred dynamic initialization occurs.
107
 
108
  If the initialization of a non-local variable with static or thread
109
- storage duration exits via an exception, `std::terminate` is called (
110
- [[except.terminate]]).
111
 
 
1
+ #### Dynamic initialization of non-local variables <a id="basic.start.dynamic">[[basic.start.dynamic]]</a>
2
 
3
  Dynamic initialization of a non-local variable with static storage
4
  duration is unordered if the variable is an implicitly or explicitly
5
  instantiated specialization, is partially-ordered if the variable is an
6
  inline variable that is not an implicitly or explicitly instantiated
 
8
 
9
  [*Note 1*: An explicitly specialized non-inline static data member or
10
  variable template specialization has ordered
11
  initialization. — *end note*]
12
 
13
+ A declaration `D` is *appearance-ordered* before a declaration `E` if
14
+
15
+ - `D` appears in the same translation unit as `E`, or
16
+ - the translation unit containing `E` has an interface dependency on the
17
+ translation unit containing `D`,
18
+
19
+ in either case prior to `E`.
20
+
21
  Dynamic initialization of non-local variables `V` and `W` with static
22
  storage duration are ordered as follows:
23
 
24
+ - If `V` and `W` have ordered initialization and the definition of `V`
25
+ is appearance-ordered before the definition of `W`, or if `V` has
26
+ partially-ordered initialization, `W` does not have unordered
27
+ initialization, and for every definition `E` of `W` there exists a
28
+ definition `D` of `V` such that `D` is appearance-ordered before `E`,
29
+ then
30
+ - if the program does not start a thread [[intro.multithread]] other
31
+ than the main thread [[basic.start.main]] or `V` and `W` have
32
+ ordered initialization and they are defined in the same translation
33
+ unit, the initialization of `V` is sequenced before the
34
+ initialization of `W`;
35
+ - otherwise, the initialization of `V` strongly happens before the
36
  initialization of `W`.
37
  - Otherwise, if the program starts a thread other than the main thread
38
  before either `V` or `W` is initialized, it is unspecified in which
39
  threads the initializations of `V` and `W` occur; the initializations
40
  are unsequenced if they occur in the same thread.
 
42
  sequenced.
43
 
44
  [*Note 2*: This definition permits initialization of a sequence of
45
  ordered variables concurrently with another sequence. — *end note*]
46
 
47
+ A *non-initialization odr-use* is an odr-use [[basic.def.odr]] not
48
  caused directly or indirectly by the initialization of a non-local
49
  static or thread storage duration variable.
50
 
51
  It is *implementation-defined* whether the dynamic initialization of a
52
  non-local non-inline variable with static storage duration is sequenced
53
  before the first statement of `main` or is deferred. If it is deferred,
54
  it strongly happens before any non-initialization odr-use of any
55
  non-inline function or non-inline variable defined in the same
56
+ translation unit as the variable to be initialized. [^29] It is
57
  *implementation-defined* in which threads and at which points in the
58
  program such deferred dynamic initialization occurs.
59
 
60
  [*Note 3*: Such points should be chosen in a way that allows the
61
  programmer to avoid deadlocks. — *end note*]
 
114
  defined in the same translation unit as the variable to be initialized.
115
  It is *implementation-defined* in which threads and at which points in
116
  the program such deferred dynamic initialization occurs.
117
 
118
  If the initialization of a non-local variable with static or thread
119
+ storage duration exits via an exception, the function `std::terminate`
120
+ is called [[except.terminate]].
121