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
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
If
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
before
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 39 |
-
[[support.start.term]]), the call to the function passed
|
| 40 |
-
`std::atexit` is sequenced before the call to the destructor for the
|
| 41 |
-
object. If a call to `std::atexit`
|
| 42 |
-
the initialization of an object with static storage
|
| 43 |
-
to the destructor for the object is sequenced before
|
| 44 |
-
function passed to `std::atexit`. If a call to
|
| 45 |
-
|
| 46 |
-
passed to the second `std::atexit` call is
|
| 47 |
-
the function passed to the first
|
|
|
|
| 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 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
| 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 |
|