C++-Standard, §15.2 schrieb:
When an exception is thrown, control is transferred to the nearest handler with a matching type (15.3); “nearest” means
the handler for which the compound-statement, ctor-initializer, or function-body following the try keyword was most
recently entered by the thread of control and not yet exited.
A throw-expression initializes a temporary object, called the exception object, the type of which is determined by re-
moving any top-level cv-qualifiers from the static type of the operand of throw and adjusting the type from “array of T”
or “function returning T” to “pointer to T” or “pointer to function returning T”, respectively. [ Note: the temporary object
created for a throw-expression that is a string literal is never of type char* or wchar_t*; that is, the special conversions
for string literals from the types “array of const char” and “array of const wchar_t” to the types “pointer to char”
and “pointer to wchar_t”, respectively (4.2), are never applied to a throw-expression. — end note ] The temporary is
an lvalue and is used to initialize the variable named in the matching handler (15.3). The type of the throw-expression
shall not be an incomplete type, or a pointer to an incomplete type other than (possibly cv-qualified) void. Except for
these restrictions and the restrictions on type matching mentioned in 15.3, the operand of throw is treated exactly as a
function argument in a call (5.2.2) or the operand of a return statement.
The memory for the temporary copy of the exception being thrown is allocated in an unspecified way, except as noted in
The temporary persists as long as there is a handler being executed for that exception. In particular, if a handler
exits by executing a throw; statement, that passes control to another handler for the same exception, so the temporary
remains. When the last remaining active handler for the exception exits by any means other than throw; the temporary
object is destroyed and the implementation may deallocate the memory for the temporary object; any such deallocation
is done in an unspecified way. The destruction occurs immediately after the destruction of the object declared in the
exception-declaration in the handler.
If the use of the temporary object can be eliminated without changing the meaning of the program except for the
execution of constructors and destructors associated with the use of the temporary object (12.2), then the exception in
the handler can be initialized directly with the argument of the throw expression. When the thrown object is a class
object, and the copy constructor used to initialize the temporary copy is not accessible, the program is ill-formed (even
when the temporary object could otherwise be eliminated). Similarly, if the destructor for that object is not accessible,
the program is ill-formed (even when the temporary object could otherwise be eliminated).
Interessante Stellen von mir hervorgehoben.
Entschuldigung für die schlechte Formatierung, so sieht das eben aus, wenn man aus einem formatierten pdf-Sokument kopiert und die Formatierungen nicht von Hand zeilenweise entfernen mag.