From Jason Turner

[except.throw]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmptfgrd87x/{from.md → to.md} +29 -16
tmp/tmptfgrd87x/{from.md → to.md} RENAMED
@@ -56,15 +56,15 @@ When an exception is thrown, control is transferred to the nearest
56
  handler with a matching type [[except.handle]]; “nearest” means the
57
  handler for which the *compound-statement* or *ctor-initializer*
58
  following the `try` keyword was most recently entered by the thread of
59
  control and not yet exited.
60
 
61
- Throwing an exception copy-initializes [[dcl.init]], [[class.copy.ctor]]
62
- a temporary object, called the *exception object*. If the type of the
63
- exception object would be an incomplete type, an abstract class type
64
- [[class.abstract]], or a pointer to an incomplete type other than
65
- cv `void` the program is ill-formed.
66
 
67
  The memory for the exception object is allocated in an unspecified way,
68
  except as noted in  [[basic.stc.dynamic.allocation]]. If a handler exits
69
  by rethrowing, control is passed to another handler for the same
70
  exception object. The points of potential destruction for the exception
@@ -89,27 +89,40 @@ object; any such deallocation is done in an unspecified way.
89
 
90
  [*Note 3*: A thrown exception does not propagate to other threads
91
  unless caught, stored, and rethrown using appropriate library functions;
92
  see  [[propagation]] and  [[futures]]. — *end note*]
93
 
94
- When the thrown object is a class object, the constructor selected for
95
- the copy-initialization as well as the constructor selected for a
96
- copy-initialization considering the thrown object as an lvalue shall be
97
- non-deleted and accessible, even if the copy/move operation is elided
98
- [[class.copy.elision]]. The destructor is potentially invoked
99
- [[class.dtor]].
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
  An exception is considered caught when a handler for that exception
102
  becomes active [[except.handle]].
103
 
104
- [*Note 4*: An exception can have active handlers and still be
105
  considered uncaught if it is rethrown. — *end note*]
106
 
107
  If the exception handling mechanism handling an uncaught exception
108
- [[except.uncaught]] directly invokes a function that exits via an
109
- exception, the function `std::terminate` is invoked
110
- [[except.terminate]].
111
 
112
  [*Example 2*:
113
 
114
  ``` cpp
115
  struct C {
@@ -129,8 +142,8 @@ int main() {
129
  }
130
  ```
131
 
132
  — *end example*]
133
 
134
- [*Note 5*: If a destructor directly invoked by stack unwinding exits
135
  via an exception, `std::terminate` is invoked. — *end note*]
136
 
 
56
  handler with a matching type [[except.handle]]; “nearest” means the
57
  handler for which the *compound-statement* or *ctor-initializer*
58
  following the `try` keyword was most recently entered by the thread of
59
  control and not yet exited.
60
 
61
+ Throwing an exception initializes an object with dynamic storage
62
+ duration, called the *exception object*. If the type of the exception
63
+ object would be an incomplete type [[basic.types.general]], an abstract
64
+ class type [[class.abstract]], or a pointer to an incomplete type other
65
+ than cv `void` [[basic.compound]], the program is ill-formed.
66
 
67
  The memory for the exception object is allocated in an unspecified way,
68
  except as noted in  [[basic.stc.dynamic.allocation]]. If a handler exits
69
  by rethrowing, control is passed to another handler for the same
70
  exception object. The points of potential destruction for the exception
 
89
 
90
  [*Note 3*: A thrown exception does not propagate to other threads
91
  unless caught, stored, and rethrown using appropriate library functions;
92
  see  [[propagation]] and  [[futures]]. — *end note*]
93
 
94
+ Let `T` denote the type of the exception object. Copy-initialization of
95
+ an object of type `T` from an lvalue of type `const T` in a context
96
+ unrelated to `T` shall be well-formed. If `T` is a class type, the
97
+ selected constructor is odr-used [[basic.def.odr]] and the destructor of
98
+ `T` is potentially invoked [[class.dtor]].
99
+
100
+ An exception is considered *uncaught* after completing the
101
+ initialization of the exception object until completing the activation
102
+ of a handler for the exception [[except.handle]].
103
+
104
+ [*Note 4*: As a consequence, an exception is considered uncaught during
105
+ any stack unwinding resulting from it being thrown. — *end note*]
106
+
107
+ If an exception is rethrown [[expr.throw]], [[propagation]], it is
108
+ considered uncaught from the point of rethrow until the rethrown
109
+ exception is caught.
110
+
111
+ [*Note 5*: The function `std::uncaught_exceptions`
112
+ [[uncaught.exceptions]] returns the number of uncaught exceptions in the
113
+ current thread. — *end note*]
114
 
115
  An exception is considered caught when a handler for that exception
116
  becomes active [[except.handle]].
117
 
118
+ [*Note 6*: An exception can have active handlers and still be
119
  considered uncaught if it is rethrown. — *end note*]
120
 
121
  If the exception handling mechanism handling an uncaught exception
122
+ directly invokes a function that exits via an exception, the function
123
+ `std::terminate` is invoked [[except.terminate]].
 
124
 
125
  [*Example 2*:
126
 
127
  ``` cpp
128
  struct C {
 
142
  }
143
  ```
144
 
145
  — *end example*]
146
 
147
+ [*Note 7*: If a destructor directly invoked by stack unwinding exits
148
  via an exception, `std::terminate` is invoked. — *end note*]
149