Created on 2014-06-03.00:00:00 last changed 74 months ago
According to 18.4 [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 11.4.2 [dcl.fct.def.default] paragraph 3,
If a function that is explicitly defaulted has an explicit exception-specification that is not compatible (18.4 [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.
This request for a language extension should be evaluated by EWG before any action is taken.