This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.

4598. §[res.on.exception.handling] should cover exceptions specified outside a Throws: paragraph

Section: 16.4.6.14 [res.on.exception.handling] Status: New Submitter: Louis Dionne Opened: 2026-06-18 Last modified: 2026-06-21

Priority: Not Prioritized

View other active issues in [res.on.exception.handling].

View all other issues in [res.on.exception.handling].

View all issues with New status.

Discussion:

16.4.6.14 [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, 22.6.5 [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, 16.4.6.14 [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.

Proposed resolution:

This wording is relative to N5046.

  1. Modify 16.4.6.14 [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 (14.4 [except.handle]) for the base type.