tmp/tmpy53yi0fr/{from.md → to.md}
RENAMED
|
@@ -1,154 +1,136 @@
|
|
| 1 |
## Special functions <a id="except.special">[[except.special]]</a>
|
| 2 |
|
| 3 |
-
The
|
| 4 |
-
|
| 5 |
-
handling mechanism
|
| 6 |
-
|
| 7 |
-
[[
|
| 8 |
-
|
| 9 |
-
handled exception.
|
| 10 |
|
| 11 |
### The `std::terminate()` function <a id="except.terminate">[[except.terminate]]</a>
|
| 12 |
|
| 13 |
In some situations exception handling must be abandoned for less subtle
|
| 14 |
-
error handling techniques.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
- when the exception handling mechanism, after completing the
|
| 17 |
initialization of the exception object but before activation of a
|
| 18 |
handler for the exception ([[except.throw]]), calls a function that
|
| 19 |
exits via an exception, or
|
| 20 |
- when the exception handling mechanism cannot find a handler for a
|
| 21 |
thrown exception ([[except.handle]]), or
|
| 22 |
- when the search for a handler ([[except.handle]]) encounters the
|
| 23 |
-
outermost block of a function with a
|
| 24 |
-
|
| 25 |
- when the destruction of an object during stack unwinding (
|
| 26 |
[[except.ctor]]) terminates by throwing an exception, or
|
| 27 |
- when initialization of a non-local variable with static or thread
|
| 28 |
-
storage duration ([[basic.start.
|
| 29 |
- when destruction of an object with static or thread storage duration
|
| 30 |
exits via an exception ([[basic.start.term]]), or
|
| 31 |
- when execution of a function registered with `std::atexit` or
|
| 32 |
`std::at_quick_exit` exits via an exception ([[support.start.term]]),
|
| 33 |
or
|
| 34 |
-
- when a *throw-expression* with no operand attempts
|
| 35 |
-
exception and no exception is being handled (
|
| 36 |
-
|
| 37 |
-
previously violated *dynamic-exception-specification*, and
|
| 38 |
-
`std::bad_exception` is not included in that
|
| 39 |
-
*dynamic-exception-specifica{-}tion* ([[except.unexpected]]), or
|
| 40 |
-
- when the implementation’s default unexpected exception handler is
|
| 41 |
-
called ([[unexpected.handler]]), or
|
| 42 |
- when the function `std::nested_exception::rethrow_nested` is called
|
| 43 |
for an object that has captured no exception ([[except.nested]]), or
|
| 44 |
- when execution of the initial function of a thread exits via an
|
| 45 |
exception ([[thread.thread.constr]]), or
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
- when the destructor or the copy assignment operator is invoked on an
|
| 47 |
object of type `std::thread` that refers to a joinable thread (
|
| 48 |
-
[[thread.thread.destr]], [[thread.thread.assign]])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
In such cases, `std::terminate()` is called ([[exception.terminate]]).
|
| 51 |
In the situation where no matching handler is found, it is
|
| 52 |
*implementation-defined* whether or not the stack is unwound before
|
| 53 |
`std::terminate()` is called. In the situation where the search for a
|
| 54 |
handler ([[except.handle]]) encounters the outermost block of a
|
| 55 |
-
function with a
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
`std::terminate()`.
|
| 63 |
|
| 64 |
-
### The `std::
|
| 65 |
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
case, the constraints in the following paragraph apply.
|
| 75 |
-
|
| 76 |
-
The `std::unexpected()` function shall not return, but it can throw (or
|
| 77 |
-
re-throw) an exception. If it throws a new exception which is allowed by
|
| 78 |
-
the exception specification which previously was violated, then the
|
| 79 |
-
search for another handler will continue at the call of the function
|
| 80 |
-
whose exception specification was violated. If it throws or rethrows an
|
| 81 |
-
exception that the * dynamic-exception-specification* does not allow
|
| 82 |
-
then the following happens: If the * dynamic-exception-specification*
|
| 83 |
-
does not include the class `std::bad_exception` ([[bad.exception]])
|
| 84 |
-
then the function `std::terminate()` is called, otherwise the thrown
|
| 85 |
-
exception is replaced by an implementation-defined object of the type
|
| 86 |
-
`std::bad_exception` and the search for another handler will continue at
|
| 87 |
-
the call of the function whose * dynamic-exception-specification* was
|
| 88 |
-
violated.
|
| 89 |
-
|
| 90 |
-
Thus, a *dynamic-exception-specification* guarantees that only the
|
| 91 |
-
listed exceptions will be thrown. If the
|
| 92 |
-
* dynamic-exception-specification* includes the type
|
| 93 |
-
`std::bad_exception` then any exception not on the list may be replaced
|
| 94 |
-
by `std::bad_exception` within the function `std::unexpected()`.
|
| 95 |
-
|
| 96 |
-
### The `std::uncaught_exception()` function <a id="except.uncaught">[[except.uncaught]]</a>
|
| 97 |
-
|
| 98 |
-
The function `std::uncaught_exception()` returns `true` after completing
|
| 99 |
-
the initialization of the exception object ([[except.throw]]) until
|
| 100 |
-
completing the activation of a handler for the exception (
|
| 101 |
-
[[except.handle]], [[uncaught]]). This includes stack unwinding. If the
|
| 102 |
-
exception is rethrown ([[except.throw]]), `std::uncaught_exception()`
|
| 103 |
-
returns `true` from the point of rethrow until the rethrown exception is
|
| 104 |
-
caught again.
|
| 105 |
|
| 106 |
<!-- Link reference definitions -->
|
| 107 |
-
[
|
|
|
|
| 108 |
[basic.def.odr]: basic.md#basic.def.odr
|
| 109 |
[basic.lookup]: basic.md#basic.lookup
|
| 110 |
-
[basic.start.
|
|
|
|
| 111 |
[basic.start.term]: basic.md#basic.start.term
|
| 112 |
[basic.stc.dynamic.allocation]: basic.md#basic.stc.dynamic.allocation
|
| 113 |
[basic.stc.dynamic.deallocation]: basic.md#basic.stc.dynamic.deallocation
|
| 114 |
-
[class.base.init]: special.md#class.base.init
|
| 115 |
[class.copy]: special.md#class.copy
|
| 116 |
[class.dtor]: special.md#class.dtor
|
| 117 |
-
[
|
| 118 |
-
[class.inhctor]: special.md#class.inhctor
|
| 119 |
-
[conv]: conv.md#conv
|
| 120 |
[conv.ptr]: conv.md#conv.ptr
|
|
|
|
|
|
|
| 121 |
[dcl.init]: dcl.md#dcl.init
|
| 122 |
-
[depr]: future.md#depr
|
| 123 |
[except]: #except
|
| 124 |
[except.ctor]: #except.ctor
|
| 125 |
[except.handle]: #except.handle
|
| 126 |
[except.nested]: language.md#except.nested
|
| 127 |
[except.spec]: #except.spec
|
| 128 |
[except.special]: #except.special
|
| 129 |
[except.terminate]: #except.terminate
|
| 130 |
[except.throw]: #except.throw
|
| 131 |
[except.uncaught]: #except.uncaught
|
| 132 |
-
[except.unexpected]: #except.unexpected
|
| 133 |
[exception.terminate]: language.md#exception.terminate
|
| 134 |
-
[
|
|
|
|
|
|
|
|
|
|
| 135 |
[expr.const]: expr.md#expr.const
|
| 136 |
[expr.dynamic.cast]: expr.md#expr.dynamic.cast
|
| 137 |
[expr.new]: expr.md#expr.new
|
|
|
|
| 138 |
[expr.typeid]: expr.md#expr.typeid
|
| 139 |
[futures]: thread.md#futures
|
|
|
|
|
|
|
| 140 |
[over.match]: over.md#over.match
|
| 141 |
[over.over]: over.md#over.over
|
| 142 |
[propagation]: language.md#propagation
|
| 143 |
-
[
|
| 144 |
-
[special]: special.md#special
|
| 145 |
[stmt.return]: stmt.md#stmt.return
|
| 146 |
[stmt.stmt]: stmt.md#stmt.stmt
|
| 147 |
[structure.specifications]: library.md#structure.specifications
|
| 148 |
[support.start.term]: language.md#support.start.term
|
| 149 |
-
[temp.
|
|
|
|
|
|
|
| 150 |
[thread.thread.assign]: thread.md#thread.thread.assign
|
| 151 |
[thread.thread.constr]: thread.md#thread.thread.constr
|
| 152 |
[thread.thread.destr]: thread.md#thread.thread.destr
|
| 153 |
-
[uncaught]: language.md#uncaught
|
| 154 |
-
[unexpected.handler]: future.md#unexpected.handler
|
|
|
|
| 1 |
## Special functions <a id="except.special">[[except.special]]</a>
|
| 2 |
|
| 3 |
+
The function `std::terminate()` ([[except.terminate]]) is used by the
|
| 4 |
+
exception handling mechanism for coping with errors related to the
|
| 5 |
+
exception handling mechanism itself. The function
|
| 6 |
+
`std::current_exception()` ([[propagation]]) and the class
|
| 7 |
+
`std::nested_exception` ([[except.nested]]) can be used by a program to
|
| 8 |
+
capture the currently handled exception.
|
|
|
|
| 9 |
|
| 10 |
### The `std::terminate()` function <a id="except.terminate">[[except.terminate]]</a>
|
| 11 |
|
| 12 |
In some situations exception handling must be abandoned for less subtle
|
| 13 |
+
error handling techniques.
|
| 14 |
+
|
| 15 |
+
[*Note 1*:
|
| 16 |
+
|
| 17 |
+
These situations are:
|
| 18 |
|
| 19 |
- when the exception handling mechanism, after completing the
|
| 20 |
initialization of the exception object but before activation of a
|
| 21 |
handler for the exception ([[except.throw]]), calls a function that
|
| 22 |
exits via an exception, or
|
| 23 |
- when the exception handling mechanism cannot find a handler for a
|
| 24 |
thrown exception ([[except.handle]]), or
|
| 25 |
- when the search for a handler ([[except.handle]]) encounters the
|
| 26 |
+
outermost block of a function with a non-throwing exception
|
| 27 |
+
specification ([[except.spec]]), or
|
| 28 |
- when the destruction of an object during stack unwinding (
|
| 29 |
[[except.ctor]]) terminates by throwing an exception, or
|
| 30 |
- when initialization of a non-local variable with static or thread
|
| 31 |
+
storage duration ([[basic.start.dynamic]]) exits via an exception, or
|
| 32 |
- when destruction of an object with static or thread storage duration
|
| 33 |
exits via an exception ([[basic.start.term]]), or
|
| 34 |
- when execution of a function registered with `std::atexit` or
|
| 35 |
`std::at_quick_exit` exits via an exception ([[support.start.term]]),
|
| 36 |
or
|
| 37 |
+
- when a *throw-expression* ([[expr.throw]]) with no operand attempts
|
| 38 |
+
to rethrow an exception and no exception is being handled (
|
| 39 |
+
[[except.throw]]), or
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
- when the function `std::nested_exception::rethrow_nested` is called
|
| 41 |
for an object that has captured no exception ([[except.nested]]), or
|
| 42 |
- when execution of the initial function of a thread exits via an
|
| 43 |
exception ([[thread.thread.constr]]), or
|
| 44 |
+
- for a parallel algorithm whose `ExecutionPolicy` specifies such
|
| 45 |
+
behavior ([[execpol.seq]], [[execpol.par]], [[execpol.parunseq]]),
|
| 46 |
+
when execution of an element access function (
|
| 47 |
+
[[algorithms.parallel.defns]]) of the parallel algorithm exits via an
|
| 48 |
+
exception ([[algorithms.parallel.exceptions]]), or
|
| 49 |
- when the destructor or the copy assignment operator is invoked on an
|
| 50 |
object of type `std::thread` that refers to a joinable thread (
|
| 51 |
+
[[thread.thread.destr]], [[thread.thread.assign]]), or
|
| 52 |
+
- when a call to a `wait()`, `wait_until()`, or `wait_for()` function on
|
| 53 |
+
a condition variable ([[thread.condition.condvar]],
|
| 54 |
+
[[thread.condition.condvarany]]) fails to meet a postcondition.
|
| 55 |
+
|
| 56 |
+
— *end note*]
|
| 57 |
|
| 58 |
In such cases, `std::terminate()` is called ([[exception.terminate]]).
|
| 59 |
In the situation where no matching handler is found, it is
|
| 60 |
*implementation-defined* whether or not the stack is unwound before
|
| 61 |
`std::terminate()` is called. In the situation where the search for a
|
| 62 |
handler ([[except.handle]]) encounters the outermost block of a
|
| 63 |
+
function with a non-throwing exception specification ([[except.spec]]),
|
| 64 |
+
it is *implementation-defined* whether the stack is unwound, unwound
|
| 65 |
+
partially, or not unwound at all before `std::terminate()` is called. In
|
| 66 |
+
all other situations, the stack shall not be unwound before
|
| 67 |
+
`std::terminate()` is called. An implementation is not permitted to
|
| 68 |
+
finish stack unwinding prematurely based on a determination that the
|
| 69 |
+
unwind process will eventually cause a call to `std::terminate()`.
|
|
|
|
| 70 |
|
| 71 |
+
### The `std::uncaught_exceptions()` function <a id="except.uncaught">[[except.uncaught]]</a>
|
| 72 |
|
| 73 |
+
An exception is considered uncaught after completing the initialization
|
| 74 |
+
of the exception object ([[except.throw]]) until completing the
|
| 75 |
+
activation of a handler for the exception ([[except.handle]]). This
|
| 76 |
+
includes stack unwinding. If an exception is rethrown ([[expr.throw]],
|
| 77 |
+
[[propagation]]), it is considered uncaught from the point of rethrow
|
| 78 |
+
until the rethrown exception is caught. The function
|
| 79 |
+
`std::uncaught_exceptions()` ([[uncaught.exceptions]]) returns the
|
| 80 |
+
number of uncaught exceptions in the current thread.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
<!-- Link reference definitions -->
|
| 83 |
+
[algorithms.parallel.defns]: algorithms.md#algorithms.parallel.defns
|
| 84 |
+
[algorithms.parallel.exceptions]: algorithms.md#algorithms.parallel.exceptions
|
| 85 |
[basic.def.odr]: basic.md#basic.def.odr
|
| 86 |
[basic.lookup]: basic.md#basic.lookup
|
| 87 |
+
[basic.start.dynamic]: basic.md#basic.start.dynamic
|
| 88 |
+
[basic.start.main]: basic.md#basic.start.main
|
| 89 |
[basic.start.term]: basic.md#basic.start.term
|
| 90 |
[basic.stc.dynamic.allocation]: basic.md#basic.stc.dynamic.allocation
|
| 91 |
[basic.stc.dynamic.deallocation]: basic.md#basic.stc.dynamic.deallocation
|
|
|
|
| 92 |
[class.copy]: special.md#class.copy
|
| 93 |
[class.dtor]: special.md#class.dtor
|
| 94 |
+
[conv.fctptr]: conv.md#conv.fctptr
|
|
|
|
|
|
|
| 95 |
[conv.ptr]: conv.md#conv.ptr
|
| 96 |
+
[conv.qual]: conv.md#conv.qual
|
| 97 |
+
[dcl.fct]: dcl.md#dcl.fct
|
| 98 |
[dcl.init]: dcl.md#dcl.init
|
| 99 |
+
[depr.except.spec]: future.md#depr.except.spec
|
| 100 |
[except]: #except
|
| 101 |
[except.ctor]: #except.ctor
|
| 102 |
[except.handle]: #except.handle
|
| 103 |
[except.nested]: language.md#except.nested
|
| 104 |
[except.spec]: #except.spec
|
| 105 |
[except.special]: #except.special
|
| 106 |
[except.terminate]: #except.terminate
|
| 107 |
[except.throw]: #except.throw
|
| 108 |
[except.uncaught]: #except.uncaught
|
|
|
|
| 109 |
[exception.terminate]: language.md#exception.terminate
|
| 110 |
+
[execpol.par]: utilities.md#execpol.par
|
| 111 |
+
[execpol.parunseq]: utilities.md#execpol.parunseq
|
| 112 |
+
[execpol.seq]: utilities.md#execpol.seq
|
| 113 |
+
[expr.call]: expr.md#expr.call
|
| 114 |
[expr.const]: expr.md#expr.const
|
| 115 |
[expr.dynamic.cast]: expr.md#expr.dynamic.cast
|
| 116 |
[expr.new]: expr.md#expr.new
|
| 117 |
+
[expr.throw]: expr.md#expr.throw
|
| 118 |
[expr.typeid]: expr.md#expr.typeid
|
| 119 |
[futures]: thread.md#futures
|
| 120 |
+
[intro.execution]: intro.md#intro.execution
|
| 121 |
+
[intro.races]: intro.md#intro.races
|
| 122 |
[over.match]: over.md#over.match
|
| 123 |
[over.over]: over.md#over.over
|
| 124 |
[propagation]: language.md#propagation
|
| 125 |
+
[stmt.jump]: stmt.md#stmt.jump
|
|
|
|
| 126 |
[stmt.return]: stmt.md#stmt.return
|
| 127 |
[stmt.stmt]: stmt.md#stmt.stmt
|
| 128 |
[structure.specifications]: library.md#structure.specifications
|
| 129 |
[support.start.term]: language.md#support.start.term
|
| 130 |
+
[temp.explicit]: temp.md#temp.explicit
|
| 131 |
+
[thread.condition.condvar]: thread.md#thread.condition.condvar
|
| 132 |
+
[thread.condition.condvarany]: thread.md#thread.condition.condvarany
|
| 133 |
[thread.thread.assign]: thread.md#thread.thread.assign
|
| 134 |
[thread.thread.constr]: thread.md#thread.thread.constr
|
| 135 |
[thread.thread.destr]: thread.md#thread.thread.destr
|
| 136 |
+
[uncaught.exceptions]: language.md#uncaught.exceptions
|
|
|