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

2024-04-18


1934. Relaxing exception-specification compatibility requirements

Section: 14.5  [except.spec]     Status: NAD     Submitter: Vinny Romano     Date: 2014-06-03

According to 14.5 [except.spec] paragraph 4,

If any declaration of a function has an exception-specification that is not a noexcept-specification allowing all exceptions, all declarations, including the definition and any explicit specialization, of that function shall have a compatible exception-specification.

This seems excessive for explicit specializations, considering that paragraph 6 applies a looser requirement for virtual functions:

If a virtual function has an exception-specification, all declarations, including the definition, of any function that overrides that virtual function in any derived class shall only allow exceptions that are allowed by the exception-specification of the base class virtual function.

The rule in paragraph 3 is also problematic in regard to explicit specializations of destructors and defaulted special member functions, as the implicit exception-specification of the template member function cannot be determined.

There is also a related problem with defaulted special member functions and exception-specifications. According to 9.5.2 [dcl.fct.def.default] paragraph 3,

If a function that is explicitly defaulted has an explicit exception-specification that is not compatible (14.5 [except.spec]) with the exception-specification on the implicit declaration, then

This rule precludes defaulting a virtual base class destructor or copy/move functions if the derived class function will throw an exception not allowed by the implicit base class member function.

Rationale (June, 2014):

This request for a language extension should be evaluated by EWG before any action is taken.

Additional note, November, 2020:

This request applied to full exception specifications and is no longer relevant in the current language, where only noexcept-specifiers are permitted.

EWG 2022-11-11

Close as NAD.