Title
§[res.on.exception.handling] should cover exceptions specified outside a Throws: paragraph
Status
new
Section
[res.on.exception.handling]
Submitter
Louis Dionne

Created on 2026-06-18.00:00:00 last changed 6 days ago

Messages

Date: 2026-06-20.12:37:19

Proposed resolution:

This wording is relative to N5046.

  1. Modify [res.on.exception.handling] as indicated:

    -1- Any of the functions defined in the C++ standard library can report a failure by throwing an exception of a type described in its Throws: paragraphthat the function is specified to throw (whether in a Throws: paragraph or elsewhere in its specification), or of a type derived from a type named in the Throws: paragraphsuch a type that would be caught by a handler ([except.handle]) for the base type.

Date: 2026-06-18.00:00:00

[res.on.exception.handling] p1 permits a standard library function to throw a type derived from the one it is specified to throw:

Any of the functions defined in the C++ standard library can report a failure by throwing an exception of a type described in its Throws: paragraph, or of a type derived from a type named in the Throws: paragraph that would be caught by a handler for the base type.

This is worded purely in terms of the function's Throws: paragraph. However, many functions specify the exception they throw outside of a Throws: paragraph. For example, `std::get` on a variant specifies it in an Effects: clause, [variant.get] p7:

Effects: If `v.index()` is `I`, returns a reference to the object stored in the variant. Otherwise, throws an exception of type `bad_variant_access`.

Read literally, [res.on.exception.handling] p1 does not grant implementations the ability to throw a derived type, because the exception is described in an Effects: paragraph. I believe this is unintended: the permission should apply whenever the standard specifies that a function throws an exception of a given type, regardless of which clause says so.

History
Date User Action Args
2026-06-20 12:37:19adminsetmessages: + msg16490
2026-06-18 00:00:00admincreate