This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-10-26
[Accepted as a DR at the June, 2023 meeting.]
Subclause 7.6.18 [expr.throw] paragraph 2 and 3 specify:
Evaluating a throw-expression with an operand throws an exception (14.2 [except.throw]); the type of the exception object is determined by removing any top-level cv-qualifier s from the static type of the operand and adjusting the type from “array of T” or function type T to “pointer to T”.
A throw-expression with no operand rethrows the currently handled exception (14.4 [except.handle]). The exception is reactivated with the existing exception object; no new exception object is created. The exception is no longer considered to be caught.
This means that throwing a value of type const char[3] would throw a char* rather than const char*, which is not intended.
Proposed resolution (approved by CWG 2023-03-03):
Change in 7.6.18 [expr.throw] paragraph 2 through 4 as follows:
Evaluating aA throw-expression with an operand throws an exception (14.2 [except.throw]); the. The array-to-pointer (7.3.3 [conv.array]) and function-to-pointer (7.3.4 [conv.func]) standard conversions are performed on the operand. The type of the exception object is determined by removing any top-level cv-qualifiers from thestatictype of the (possibly converted) operandand adjusting the type from “array of T” or function type T to “pointer to T”.A throw-expression with no operand rethrows the currently handled exception (14.4 [except.handle]). If no exception is presently being handled, the function std:: terminate is invoked (14.6.2 [except.terminate]).
TheOtherwise, the exception is reactivated with the existing exception object; no new exception object is created. The exception is no longer considered to be caught.
If no exception is presently being handled, evaluating a throw-expression with no operand calls std:: terminate() (14.6.2 [except.terminate]).