tmp/tmpqxt33cld/{from.md → to.md}
RENAMED
|
@@ -71,46 +71,19 @@ The declaration of `D::f` is ill-formed because it has a
|
|
| 71 |
potentially-throwing exception specification, whereas `B::f` has a
|
| 72 |
non-throwing exception specification.
|
| 73 |
|
| 74 |
— *end example*]
|
| 75 |
|
| 76 |
-
Whenever an exception is thrown and the search for a handler
|
| 77 |
-
[[except.handle]] encounters the outermost block of a function with a
|
| 78 |
-
non-throwing exception specification, the function `std::terminate` is
|
| 79 |
-
invoked [[except.terminate]].
|
| 80 |
-
|
| 81 |
-
[*Note 1*: An implementation is not permitted to reject an expression
|
| 82 |
-
merely because, when executed, it throws or might throw an exception
|
| 83 |
-
from a function with a non-throwing exception
|
| 84 |
-
specification. — *end note*]
|
| 85 |
-
|
| 86 |
-
[*Example 3*:
|
| 87 |
-
|
| 88 |
-
``` cpp
|
| 89 |
-
extern void f(); // potentially-throwing
|
| 90 |
-
|
| 91 |
-
void g() noexcept {
|
| 92 |
-
f(); // valid, even if f throws
|
| 93 |
-
throw 42; // valid, effectively a call to std::terminate
|
| 94 |
-
}
|
| 95 |
-
```
|
| 96 |
-
|
| 97 |
-
The call to `f` is well-formed despite the possibility for it to throw
|
| 98 |
-
an exception.
|
| 99 |
-
|
| 100 |
-
— *end example*]
|
| 101 |
-
|
| 102 |
An expression E is *potentially-throwing* if
|
| 103 |
|
| 104 |
- E is a function call [[expr.call]] whose *postfix-expression* has a
|
| 105 |
function type, or a pointer-to-function type, with a
|
| 106 |
potentially-throwing exception specification, or
|
| 107 |
- E implicitly invokes a function (such as an overloaded operator, an
|
| 108 |
allocation function in a *new-expression*, a constructor for a
|
| 109 |
-
function argument, or a destructor
|
| 110 |
-
|
| 111 |
-
specification, or
|
| 112 |
- E is a *throw-expression* [[expr.throw]], or
|
| 113 |
- E is a `dynamic_cast` expression that casts to a reference type and
|
| 114 |
requires a runtime check [[expr.dynamic.cast]], or
|
| 115 |
- E is a `typeid` expression applied to a (possibly parenthesized)
|
| 116 |
built-in unary `*` operator applied to a pointer to a polymorphic
|
|
@@ -128,11 +101,11 @@ only if any of the following constructs is potentially-throwing:
|
|
| 128 |
potentially constructed subobject, or
|
| 129 |
- a subexpression of such an initialization, such as a default argument
|
| 130 |
expression, or,
|
| 131 |
- for a default constructor, a default member initializer.
|
| 132 |
|
| 133 |
-
[*Note
|
| 134 |
invoked when an exception is thrown during the execution of a
|
| 135 |
constructor [[except.ctor]], their exception specifications do not
|
| 136 |
contribute to the exception specification of the constructor, because an
|
| 137 |
exception thrown from such a destructor would call the function
|
| 138 |
`std::terminate` rather than escape the constructor
|
|
@@ -158,11 +131,11 @@ specification.
|
|
| 158 |
The exception specification for a comparison operator function
|
| 159 |
[[over.binary]] without a *noexcept-specifier* that is defaulted on its
|
| 160 |
first declaration is potentially-throwing if and only if any expression
|
| 161 |
in the implicit definition is potentially-throwing.
|
| 162 |
|
| 163 |
-
[*Example
|
| 164 |
|
| 165 |
``` cpp
|
| 166 |
struct A {
|
| 167 |
A(int = (A(5), 0)) noexcept;
|
| 168 |
A(const A&) noexcept;
|
|
@@ -194,23 +167,21 @@ base class function has a non-throwing exception specification.
|
|
| 194 |
|
| 195 |
An exception specification is considered to be *needed* when:
|
| 196 |
|
| 197 |
- in an expression, the function is selected by overload resolution
|
| 198 |
[[over.match]], [[over.over]];
|
| 199 |
-
- the function is odr-used [[term.odr.use]]
|
| 200 |
-
unevaluated operand, would be odr-used if the expression were
|
| 201 |
-
potentially-evaluated;
|
| 202 |
- the exception specification is compared to that of another declaration
|
| 203 |
(e.g., an explicit specialization or an overriding virtual function);
|
| 204 |
- the function is defined; or
|
| 205 |
- the exception specification is needed for a defaulted function that
|
| 206 |
-
calls the function. \[*Note
|
| 207 |
require the exception specification of a base member function to be
|
| 208 |
evaluated until the implicit exception specification of the derived
|
| 209 |
function is needed, but an explicit *noexcept-specifier* needs the
|
| 210 |
implicit exception specification to compare against. — *end note*]
|
| 211 |
|
| 212 |
The exception specification of a defaulted function is evaluated as
|
| 213 |
described above only when needed; similarly, the *noexcept-specifier* of
|
| 214 |
-
a specialization of a
|
| 215 |
-
|
| 216 |
|
|
|
|
| 71 |
potentially-throwing exception specification, whereas `B::f` has a
|
| 72 |
non-throwing exception specification.
|
| 73 |
|
| 74 |
— *end example*]
|
| 75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
An expression E is *potentially-throwing* if
|
| 77 |
|
| 78 |
- E is a function call [[expr.call]] whose *postfix-expression* has a
|
| 79 |
function type, or a pointer-to-function type, with a
|
| 80 |
potentially-throwing exception specification, or
|
| 81 |
- E implicitly invokes a function (such as an overloaded operator, an
|
| 82 |
allocation function in a *new-expression*, a constructor for a
|
| 83 |
+
function argument, or a destructor) that has a potentially-throwing
|
| 84 |
+
exception specification, or
|
|
|
|
| 85 |
- E is a *throw-expression* [[expr.throw]], or
|
| 86 |
- E is a `dynamic_cast` expression that casts to a reference type and
|
| 87 |
requires a runtime check [[expr.dynamic.cast]], or
|
| 88 |
- E is a `typeid` expression applied to a (possibly parenthesized)
|
| 89 |
built-in unary `*` operator applied to a pointer to a polymorphic
|
|
|
|
| 101 |
potentially constructed subobject, or
|
| 102 |
- a subexpression of such an initialization, such as a default argument
|
| 103 |
expression, or,
|
| 104 |
- for a default constructor, a default member initializer.
|
| 105 |
|
| 106 |
+
[*Note 1*: Even though destructors for fully-constructed subobjects are
|
| 107 |
invoked when an exception is thrown during the execution of a
|
| 108 |
constructor [[except.ctor]], their exception specifications do not
|
| 109 |
contribute to the exception specification of the constructor, because an
|
| 110 |
exception thrown from such a destructor would call the function
|
| 111 |
`std::terminate` rather than escape the constructor
|
|
|
|
| 131 |
The exception specification for a comparison operator function
|
| 132 |
[[over.binary]] without a *noexcept-specifier* that is defaulted on its
|
| 133 |
first declaration is potentially-throwing if and only if any expression
|
| 134 |
in the implicit definition is potentially-throwing.
|
| 135 |
|
| 136 |
+
[*Example 3*:
|
| 137 |
|
| 138 |
``` cpp
|
| 139 |
struct A {
|
| 140 |
A(int = (A(5), 0)) noexcept;
|
| 141 |
A(const A&) noexcept;
|
|
|
|
| 167 |
|
| 168 |
An exception specification is considered to be *needed* when:
|
| 169 |
|
| 170 |
- in an expression, the function is selected by overload resolution
|
| 171 |
[[over.match]], [[over.over]];
|
| 172 |
+
- the function is odr-used [[term.odr.use]];
|
|
|
|
|
|
|
| 173 |
- the exception specification is compared to that of another declaration
|
| 174 |
(e.g., an explicit specialization or an overriding virtual function);
|
| 175 |
- the function is defined; or
|
| 176 |
- the exception specification is needed for a defaulted function that
|
| 177 |
+
calls the function. \[*Note 2*: A defaulted declaration does not
|
| 178 |
require the exception specification of a base member function to be
|
| 179 |
evaluated until the implicit exception specification of the derived
|
| 180 |
function is needed, but an explicit *noexcept-specifier* needs the
|
| 181 |
implicit exception specification to compare against. — *end note*]
|
| 182 |
|
| 183 |
The exception specification of a defaulted function is evaluated as
|
| 184 |
described above only when needed; similarly, the *noexcept-specifier* of
|
| 185 |
+
a specialization of a templated function is instantiated only when
|
| 186 |
+
needed.
|
| 187 |
|