From Jason Turner

[basic.start.term]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpcl3fqxkl/{from.md → to.md} +50 -40
tmp/tmpcl3fqxkl/{from.md → to.md} RENAMED
@@ -1,64 +1,74 @@
1
  ### Termination <a id="basic.start.term">[[basic.start.term]]</a>
2
 
3
  Destructors ([[class.dtor]]) for initialized objects (that is, objects
4
- whose lifetime ([[basic.life]]) has begun) with static storage duration
5
- are called as a result of returning from `main` and as a result of
6
- calling `std::exit` ([[support.start.term]]). Destructors for
7
- initialized objects with thread storage duration within a given thread
8
- are called as a result of returning from the initial function of that
9
- thread and as a result of that thread calling `std::exit`. The
10
- completions of the destructors for all initialized objects with thread
11
- storage duration within that thread are sequenced before the initiation
12
- of the destructors of any object with static storage duration. If the
13
- completion of the constructor or dynamic initialization of an object
14
- with thread storage duration is sequenced before that of another, the
15
- completion of the destructor of the second is sequenced before the
16
- initiation of the destructor of the first. If the completion of the
17
- constructor or dynamic initialization of an object with static storage
18
- duration is sequenced before that of another, the completion of the
19
- destructor of the second is sequenced before the initiation of the
20
- destructor of the first. This definition permits concurrent destruction.
21
- If an object is initialized statically, the object is destroyed in the
22
- same order as if the object was dynamically initialized. For an object
23
- of array or class type, all subobjects of that object are destroyed
24
- before any block-scope object with static storage duration initialized
25
- during the construction of the subobjects is destroyed. If the
26
- destruction of an object with static or thread storage duration exits
27
- via an exception, `std::terminate` is called ([[except.terminate]]).
 
 
 
 
 
 
 
 
28
 
29
  If a function contains a block-scope object of static or thread storage
30
  duration that has been destroyed and the function is called during the
31
  destruction of an object with static or thread storage duration, the
32
  program has undefined behavior if the flow of control passes through the
33
  definition of the previously destroyed block-scope object. Likewise, the
34
  behavior is undefined if the block-scope object is used indirectly
35
  (i.e., through a pointer) after its destruction.
36
 
37
  If the completion of the initialization of an object with static storage
38
- duration is sequenced before a call to `std::atexit` (see `<cstdlib>`, 
39
- [[support.start.term]]), the call to the function passed to
40
- `std::atexit` is sequenced before the call to the destructor for the
41
- object. If a call to `std::atexit` is sequenced before the completion of
42
- the initialization of an object with static storage duration, the call
43
- to the destructor for the object is sequenced before the call to the
44
- function passed to `std::atexit`. If a call to `std::atexit` is
45
- sequenced before another call to `std::atexit`, the call to the function
46
- passed to the second `std::atexit` call is sequenced before the call to
47
- the function passed to the first `std::atexit` call.
 
48
 
49
  If there is a use of a standard library object or function not permitted
50
  within signal handlers ([[support.runtime]]) that does not happen
51
  before ([[intro.multithread]]) completion of destruction of objects
52
  with static storage duration and execution of `std::atexit` registered
53
  functions ([[support.start.term]]), the program has undefined behavior.
54
- If there is a use of an object with static storage duration that does
55
- not happen before the object’s destruction, the program has undefined
56
- behavior. Terminating every thread before a call to `std::exit` or the
57
- exit from `main` is sufficient, but not necessary, to satisfy these
58
- requirements. These requirements permit thread managers as
59
- static-storage-duration objects.
 
60
 
61
  Calling the function `std::abort()` declared in `<cstdlib>` terminates
62
  the program without executing any destructors and without calling the
63
  functions passed to `std::atexit()` or `std::at_quick_exit()`.
64
 
 
1
  ### Termination <a id="basic.start.term">[[basic.start.term]]</a>
2
 
3
  Destructors ([[class.dtor]]) for initialized objects (that is, objects
4
+ whose lifetime ([[basic.life]]) has begun) with static storage
5
+ duration, and functions registered with `std::atexit`, are called as
6
+ part of a call to `std::exit` ([[support.start.term]]). The call to
7
+ `std::exit` is sequenced before the invocations of the destructors and
8
+ the registered functions.
9
+
10
+ [*Note 1*: Returning from `main` invokes `std::exit` (
11
+ [[basic.start.main]]). *end note*]
12
+
13
+ Destructors for initialized objects with thread storage duration within
14
+ a given thread are called as a result of returning from the initial
15
+ function of that thread and as a result of that thread calling
16
+ `std::exit`. The completions of the destructors for all initialized
17
+ objects with thread storage duration within that thread strongly happen
18
+ before the initiation of the destructors of any object with static
19
+ storage duration.
20
+
21
+ If the completion of the constructor or dynamic initialization of an
22
+ object with static storage duration strongly happens before that of
23
+ another, the completion of the destructor of the second is sequenced
24
+ before the initiation of the destructor of the first. If the completion
25
+ of the constructor or dynamic initialization of an object with thread
26
+ storage duration is sequenced before that of another, the completion of
27
+ the destructor of the second is sequenced before the initiation of the
28
+ destructor of the first. If an object is initialized statically, the
29
+ object is destroyed in the same order as if the object was dynamically
30
+ initialized. For an object of array or class type, all subobjects of
31
+ that object are destroyed before any block-scope object with static
32
+ storage duration initialized during the construction of the subobjects
33
+ is destroyed. If the destruction of an object with static or thread
34
+ storage duration exits via an exception, `std::terminate` is called (
35
+ [[except.terminate]]).
36
 
37
  If a function contains a block-scope object of static or thread storage
38
  duration that has been destroyed and the function is called during the
39
  destruction of an object with static or thread storage duration, the
40
  program has undefined behavior if the flow of control passes through the
41
  definition of the previously destroyed block-scope object. Likewise, the
42
  behavior is undefined if the block-scope object is used indirectly
43
  (i.e., through a pointer) after its destruction.
44
 
45
  If the completion of the initialization of an object with static storage
46
+ duration strongly happens before a call to `std::atexit` (see
47
+ `<cstdlib>`,  [[support.start.term]]), the call to the function passed
48
+ to `std::atexit` is sequenced before the call to the destructor for the
49
+ object. If a call to `std::atexit` strongly happens before the
50
+ completion of the initialization of an object with static storage
51
+ duration, the call to the destructor for the object is sequenced before
52
+ the call to the function passed to `std::atexit`. If a call to
53
+ `std::atexit` strongly happens before another call to `std::atexit`, the
54
+ call to the function passed to the second `std::atexit` call is
55
+ sequenced before the call to the function passed to the first
56
+ `std::atexit` call.
57
 
58
  If there is a use of a standard library object or function not permitted
59
  within signal handlers ([[support.runtime]]) that does not happen
60
  before ([[intro.multithread]]) completion of destruction of objects
61
  with static storage duration and execution of `std::atexit` registered
62
  functions ([[support.start.term]]), the program has undefined behavior.
63
+
64
+ [*Note 2*: If there is a use of an object with static storage duration
65
+ that does not happen before the object’s destruction, the program has
66
+ undefined behavior. Terminating every thread before a call to
67
+ `std::exit` or the exit from `main` is sufficient, but not necessary, to
68
+ satisfy these requirements. These requirements permit thread managers as
69
+ static-storage-duration objects. — *end note*]
70
 
71
  Calling the function `std::abort()` declared in `<cstdlib>` terminates
72
  the program without executing any destructors and without calling the
73
  functions passed to `std::atexit()` or `std::at_quick_exit()`.
74