From Jason Turner

[except.handle]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpwm5yqqwi/{from.md → to.md} +35 -11
tmp/tmpwm5yqqwi/{from.md → to.md} RENAMED
@@ -62,36 +62,60 @@ The handlers for a try block are tried in order of appearance.
62
  [*Note 2*: This makes it possible to write handlers that can never be
63
  executed, for example by placing a handler for a final derived class
64
  after a handler for a corresponding unambiguous public base
65
  class. — *end note*]
66
 
67
- A `...` in a handler’s *exception-declaration* functions similarly to
68
- `...` in a function parameter declaration; it specifies a match for any
69
  exception. If present, a `...` handler shall be the last handler for its
70
  try block.
71
 
72
  If no match is found among the handlers for a try block, the search for
73
  a matching handler continues in a dynamically surrounding try block of
74
  the same thread.
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  A handler is considered *active* when initialization is complete for the
77
  parameter (if any) of the catch clause.
78
 
79
- [*Note 3*: The stack will have been unwound at that
80
  point. — *end note*]
81
 
82
  Also, an implicit handler is considered active when the function
83
  `std::terminate` is entered due to a throw. A handler is no longer
84
  considered active when the catch clause exits.
85
 
86
  The exception with the most recently activated handler that is still
87
  active is called the *currently handled exception*.
88
 
89
- If no matching handler is found, the function `std::terminate` is
90
- invoked; whether or not the stack is unwound before this invocation of
91
- `std::terminate` is *implementation-defined* [[except.terminate]].
92
-
93
  Referring to any non-static member or base class of an object in the
94
  handler for a *function-try-block* of a constructor or destructor for
95
  that object results in undefined behavior.
96
 
97
  Exceptions thrown in destructors of objects with static storage duration
@@ -123,10 +147,10 @@ follows:
123
 
124
  The lifetime of the variable ends when the handler exits, after the
125
  destruction of any objects with automatic storage duration initialized
126
  within the handler.
127
 
128
- When the handler declares an object, any changes to that object will not
129
- affect the exception object. When the handler declares a reference to an
130
- object, any changes to the referenced object are changes to the
131
- exception object and will have effect should that object be rethrown.
132
 
 
62
  [*Note 2*: This makes it possible to write handlers that can never be
63
  executed, for example by placing a handler for a final derived class
64
  after a handler for a corresponding unambiguous public base
65
  class. — *end note*]
66
 
67
+ A `...` in a handler’s *exception-declaration* specifies a match for any
 
68
  exception. If present, a `...` handler shall be the last handler for its
69
  try block.
70
 
71
  If no match is found among the handlers for a try block, the search for
72
  a matching handler continues in a dynamically surrounding try block of
73
  the same thread.
74
 
75
+ If the search for a handler exits the function body of a function with a
76
+ non-throwing exception specification, the function `std::terminate`
77
+ [[except.terminate]] is invoked.
78
+
79
+ [*Note 3*: An implementation is not permitted to reject an expression
80
+ merely because, when executed, it throws or might throw an exception
81
+ from a function with a non-throwing exception
82
+ specification. — *end note*]
83
+
84
+ [*Example 2*:
85
+
86
+ ``` cpp
87
+ extern void f(); // potentially-throwing
88
+
89
+ void g() noexcept {
90
+ f(); // valid, even if f throws
91
+ throw 42; // valid, effectively a call to std::terminate
92
+ }
93
+ ```
94
+
95
+ The call to `f` is well-formed despite the possibility for it to throw
96
+ an exception.
97
+
98
+ — *end example*]
99
+
100
+ If no matching handler is found, the function `std::terminate` is
101
+ invoked; whether or not the stack is unwound before this invocation of
102
+ `std::terminate` is *implementation-defined* [[except.terminate]].
103
+
104
  A handler is considered *active* when initialization is complete for the
105
  parameter (if any) of the catch clause.
106
 
107
+ [*Note 4*: The stack will have been unwound at that
108
  point. — *end note*]
109
 
110
  Also, an implicit handler is considered active when the function
111
  `std::terminate` is entered due to a throw. A handler is no longer
112
  considered active when the catch clause exits.
113
 
114
  The exception with the most recently activated handler that is still
115
  active is called the *currently handled exception*.
116
 
 
 
 
 
117
  Referring to any non-static member or base class of an object in the
118
  handler for a *function-try-block* of a constructor or destructor for
119
  that object results in undefined behavior.
120
 
121
  Exceptions thrown in destructors of objects with static storage duration
 
147
 
148
  The lifetime of the variable ends when the handler exits, after the
149
  destruction of any objects with automatic storage duration initialized
150
  within the handler.
151
 
152
+ [*Note 5*: When the handler declares an object, any changes to that
153
+ object will not affect the exception object. When the handler declares a
154
+ reference to an object, any changes to the referenced object are changes
155
+ to the exception object. *end note*]
156