tmp/tmpj9iv9skm/{from.md → to.md}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
## Constructors and destructors <a id="except.ctor">[[except.ctor]]</a>
|
| 2 |
|
| 3 |
As control passes from the point where an exception is thrown to a
|
| 4 |
-
handler, objects
|
| 5 |
-
|
| 6 |
|
| 7 |
Each object with automatic storage duration is destroyed if it has been
|
| 8 |
constructed, but not yet destroyed, since the try block was entered. If
|
| 9 |
an exception is thrown during the destruction of temporaries or local
|
| 10 |
variables for a `return` statement [[stmt.return]], the destructor for
|
|
@@ -36,23 +36,47 @@ destroyed, causing stack unwinding, resulting in the destruction of the
|
|
| 36 |
returned object, followed by the destruction of the local variable `a`.
|
| 37 |
Finally, the returned object is constructed again at \#2.
|
| 38 |
|
| 39 |
— *end example*]
|
| 40 |
|
| 41 |
-
If the initialization
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
completed [[dcl.init]] and whose destructor has not yet begun execution,
|
| 46 |
-
except that in the case of destruction, the variant members of a
|
| 47 |
-
union-like class are not destroyed.
|
| 48 |
|
| 49 |
[*Note 1*: If such an object has a reference member that extends the
|
| 50 |
lifetime of a temporary object, this ends the lifetime of the reference
|
| 51 |
member, so the lifetime of the temporary object is effectively not
|
| 52 |
extended. — *end note*]
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
The subobjects are destroyed in the reverse order of the completion of
|
| 55 |
their construction. Such destruction is sequenced before entering a
|
| 56 |
handler of the *function-try-block* of the constructor or destructor, if
|
| 57 |
any.
|
| 58 |
|
|
@@ -60,10 +84,10 @@ If the *compound-statement* of the *function-body* of a delegating
|
|
| 60 |
constructor for an object exits via an exception, the object’s
|
| 61 |
destructor is invoked. Such destruction is sequenced before entering a
|
| 62 |
handler of the *function-try-block* of a delegating constructor for that
|
| 63 |
object, if any.
|
| 64 |
|
| 65 |
-
[*Note
|
| 66 |
[[expr.new]], the matching deallocation function
|
| 67 |
[[basic.stc.dynamic.deallocation]], if any, is called to free the
|
| 68 |
storage occupied by the object. — *end note*]
|
| 69 |
|
|
|
|
| 1 |
## Constructors and destructors <a id="except.ctor">[[except.ctor]]</a>
|
| 2 |
|
| 3 |
As control passes from the point where an exception is thrown to a
|
| 4 |
+
handler, objects are destroyed by a process, specified in this
|
| 5 |
+
subclause, called *stack unwinding*.
|
| 6 |
|
| 7 |
Each object with automatic storage duration is destroyed if it has been
|
| 8 |
constructed, but not yet destroyed, since the try block was entered. If
|
| 9 |
an exception is thrown during the destruction of temporaries or local
|
| 10 |
variables for a `return` statement [[stmt.return]], the destructor for
|
|
|
|
| 36 |
returned object, followed by the destruction of the local variable `a`.
|
| 37 |
Finally, the returned object is constructed again at \#2.
|
| 38 |
|
| 39 |
— *end example*]
|
| 40 |
|
| 41 |
+
If the initialization of an object other than by delegating constructor
|
| 42 |
+
is terminated by an exception, the destructor is invoked for each of the
|
| 43 |
+
object’s subobjects that were known to be initialized by the object’s
|
| 44 |
+
initialization and whose initialization has completed [[dcl.init]].
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
[*Note 1*: If such an object has a reference member that extends the
|
| 47 |
lifetime of a temporary object, this ends the lifetime of the reference
|
| 48 |
member, so the lifetime of the temporary object is effectively not
|
| 49 |
extended. — *end note*]
|
| 50 |
|
| 51 |
+
A subobject is *known to be initialized* if its initialization is
|
| 52 |
+
specified
|
| 53 |
+
|
| 54 |
+
- in [[class.base.init]] for initialization by constructor,
|
| 55 |
+
- in [[class.copy.ctor]] for initialization by defaulted copy/move
|
| 56 |
+
constructor,
|
| 57 |
+
- in [[class.inhctor.init]] for initialization by inherited constructor,
|
| 58 |
+
- in [[dcl.init.aggr]] for aggregate initialization,
|
| 59 |
+
- in [[expr.prim.lambda.capture]] for the initialization of the closure
|
| 60 |
+
object when evaluating a *lambda-expression*,
|
| 61 |
+
- in [[dcl.init.general]] for default-initialization,
|
| 62 |
+
value-initialization, or direct-initialization of an array.
|
| 63 |
+
|
| 64 |
+
[*Note 2*: This includes virtual base class subobjects if the
|
| 65 |
+
initialization is for a complete object, and can include variant members
|
| 66 |
+
that were nominated explicitly by a *mem-initializer* or
|
| 67 |
+
*designated-initializer-clause* or that have a default member
|
| 68 |
+
initializer. — *end note*]
|
| 69 |
+
|
| 70 |
+
If the destructor of an object is terminated by an exception, each
|
| 71 |
+
destructor invocation that would be performed after executing the body
|
| 72 |
+
of the destructor [[class.dtor]] and that has not yet begun execution is
|
| 73 |
+
performed.
|
| 74 |
+
|
| 75 |
+
[*Note 3*: This includes virtual base class subobjects if the
|
| 76 |
+
destructor was invoked for a complete object. — *end note*]
|
| 77 |
+
|
| 78 |
The subobjects are destroyed in the reverse order of the completion of
|
| 79 |
their construction. Such destruction is sequenced before entering a
|
| 80 |
handler of the *function-try-block* of the constructor or destructor, if
|
| 81 |
any.
|
| 82 |
|
|
|
|
| 84 |
constructor for an object exits via an exception, the object’s
|
| 85 |
destructor is invoked. Such destruction is sequenced before entering a
|
| 86 |
handler of the *function-try-block* of a delegating constructor for that
|
| 87 |
object, if any.
|
| 88 |
|
| 89 |
+
[*Note 4*: If the object was allocated by a *new-expression*
|
| 90 |
[[expr.new]], the matching deallocation function
|
| 91 |
[[basic.stc.dynamic.deallocation]], if any, is called to free the
|
| 92 |
storage occupied by the object. — *end note*]
|
| 93 |
|