Title
Relaxing exception-specification compatibility requirements
Status
nad
Section
14.5 [except.spec]
Submitter
Vinny Romano

Created on 2014-06-03.00:00:00 last changed 16 months ago

Messages

Date: 2022-11-24.21:01:44

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.

Date: 2014-06-03.00:00:00

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

  • if the function is explicitly defaulted on its first declaration, it is defined as deleted;

  • otherwise, the program is ill-formed.

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.

History
Date User Action Args
2022-11-24 21:01:44adminsetstatus: extension -> nad
2020-12-15 00:00:00adminsetmessages: + msg6322
2014-06-03 00:00:00admincreate