|
7542 | 7542 | apply only to complete objects not having constant destruction. |
7543 | 7543 |
|
7544 | 7544 | \pnum |
7545 | | -If the completion of the constructor or dynamic initialization of an object with static |
7546 | | -storage duration strongly happens before that of another, the completion of the destructor |
7547 | | -of the second is sequenced before the initiation of the destructor of the first. |
7548 | | -If the completion of the constructor or dynamic initialization of an object with thread |
7549 | | -storage duration is sequenced before that of another, the completion of the destructor |
7550 | | -of the second is sequenced before the initiation of the destructor of the first. |
| 7545 | +If the deemed construction\iref{dcl.init.general} of a complete object with static |
| 7546 | +storage duration strongly happens before that of another, the completion of the destruction |
| 7547 | +of the second is sequenced before the initiation of the destruction of the first. |
| 7548 | +If the deemed construction of a complete object with thread |
| 7549 | +storage duration is sequenced before that of another, the completion of the destruction |
| 7550 | +of the second is sequenced before the initiation of the destruction of the first. |
7551 | 7551 | If an object is |
7552 | 7552 | initialized statically, the object is destroyed in the same order as if |
7553 | | -the object was dynamically initialized. For an object of array or class |
7554 | | -type, all subobjects of that object are destroyed before any block |
7555 | | -variable with static storage duration initialized during the construction |
7556 | | -of the subobjects is destroyed. |
| 7553 | +the object was dynamically initialized. |
7557 | 7554 | If the destruction of an object with static or thread storage duration |
7558 | 7555 | exits via an exception, |
7559 | 7556 | the function \tcode{std::terminate} is called\iref{except.terminate}. |
| 7557 | +\begin{example} |
| 7558 | +In the following program, |
| 7559 | +the elements of \tcode{a} are destroyed, |
| 7560 | +followed by \tcode{dt}, and |
| 7561 | +finally by the two \tcode{Btemp} objects: |
| 7562 | +\begin{codeblock} |
| 7563 | +struct DTemp { ~DTemp(); }; |
| 7564 | +struct Temp { |
| 7565 | + ~Temp() { |
| 7566 | + static DTemp dt; |
| 7567 | + } |
| 7568 | +}; |
| 7569 | +struct BTemp { |
| 7570 | + ~BTemp(); |
| 7571 | +}; |
| 7572 | +struct A { |
| 7573 | + const BTemp &tb; |
| 7574 | + ~A(); |
| 7575 | +}; |
| 7576 | +A a[] = { (Temp(), BTemp()), BTemp() }; |
| 7577 | + |
| 7578 | +int main() {} |
| 7579 | +\end{codeblock} |
| 7580 | +If the array \tcode{a} were an object with automatic storage duration, |
| 7581 | +the \tcode{Btemp} temporaries would be destroyed |
| 7582 | +as each element of the array is destroyed\iref{class.temporary}. |
| 7583 | +\end{example} |
7560 | 7584 |
|
7561 | 7585 | \pnum |
7562 | 7586 | If a function contains a block variable of static or thread storage duration that has been |
|
7572 | 7596 | \pnum |
7573 | 7597 | \indextext{\idxcode{atexit}}% |
7574 | 7598 | \indexlibraryglobal{atexit}% |
7575 | | -If the completion of the initialization of an object with static storage |
| 7599 | +If the deemed construction of a complete object with static storage |
7576 | 7600 | duration strongly happens before a call to \tcode{std::atexit}~(see |
7577 | 7601 | \libheader{cstdlib}, \ref{support.start.term}), the call to the function passed to |
7578 | | -\tcode{std::atexit} is sequenced before the call to the destructor for the object. If a |
7579 | | -call to \tcode{std::atexit} strongly happens before the completion of the initialization of |
7580 | | -an object with static storage duration, the call to the destructor for the |
| 7602 | +\tcode{std::atexit} is sequenced before the initiation of the destruction of the object. |
| 7603 | +If a call to \tcode{std::atexit} strongly happens before the deemed construction of |
| 7604 | +a complete object with static storage duration, |
| 7605 | +the completion of the destruction of the |
7581 | 7606 | object is sequenced before the call to the function passed to \tcode{std::atexit}. If a |
7582 | 7607 | call to \tcode{std::atexit} strongly happens before another call to \tcode{std::atexit}, the |
7583 | 7608 | call to the function passed to the second \tcode{std::atexit} call is sequenced before |
|
0 commit comments