Title
Inconsistency of throw-expression specification
Status
drwp
Section
7.6.18 [expr.throw]
Submitter
Krystian Stasiowski

Created on 2020-04-06.00:00:00 last changed 5 months ago

Messages

Date: 2023-03-03.21:02:53

Proposed resolution (approved by CWG 2023-03-03):

Change in 7.6.18 [expr.throw] paragraph 2 through 4 as follows:

Evaluating a A 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 the static type of the (possibly converted) 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]). If no exception is presently being handled, the function std:: terminate is invoked (14.6.2 [except.terminate]). The Otherwise, 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]).

Date: 2023-06-15.00:00:00

[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.

History
Date User Action Args
2023-12-19 10:15:28adminsetstatus: dr -> drwp
2023-07-16 13:00:43adminsetstatus: ready -> dr
2023-03-03 21:02:53adminsetmessages: + msg7217
2023-03-03 21:02:53adminsetstatus: open -> ready
2020-04-06 00:00:00admincreate