Movatterモバイル変換


[0]ホーム

URL:


This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 119a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-12-20


2699. Inconsistency ofthrow-expression specification

Section:7.6.18  [expr.throw]    Status:CD7    Submitter:Krystian Stasiowski    Date:2020-04-06

[Accepted as a DR at the June, 2023 meeting.]

Subclause 7.6.18 [expr.throw] paragraph 2 and 3 specify:

Evaluating athrow-expression with an operand throws anexception (14.2 [except.throw]); the type of the exceptionobject is determined by removing any top-level cv-qualifier s from thestatic type of the operand and adjusting the type from “array ofT” or function type T to “pointer to T”.

Athrow-expression with no operand rethrows the currentlyhandled exception (14.4 [except.handle]). The exception isreactivated with the existing exception object; no new exceptionobject is created. The exception is no longer considered to be caught.

This means that throwing a value of typeconst char[3]would throw achar* rather thanconst char*, whichis not intended.

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

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

Evaluating aAthrow-expression withan operand throws an exception (14.2 [except.throw]);the. The array-to-pointer (7.3.3 [conv.array]) andfunction-to-pointer (7.3.4 [conv.func]) standard conversionsare performed on the operand. The type of the exception objectis determined by removing any top-level cv-qualifiers fromthestatic type of the(possibly converted)operandand adjusting the type from “array of T” orfunction type T to “pointer to T”.

Athrow-expression with no operand rethrows the currentlyhandled exception (14.4 [except.handle]).If no exception is presently being handled, the functionstd::terminate is invoked (14.6.2 [except.terminate]).TheOtherwise, the exception isreactivated with the existing exception object; no new exceptionobject is created. The exception is no longer considered to be caught.

If no exception is presently being handled, evaluatingathrow-expression with no operand calls std:: terminate()(14.6.2 [except.terminate]).




[8]ページ先頭

©2009-2026 Movatter.jp