119. Should virtual functions be allowed to strengthen the exception specification?

Section: [res.on.exception.handling] Status: TC1 Submitter: Judy Ward Opened: 1998-12-15 Last modified: 2016-01-28 10:19:27 UTC

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 TC1 status.


Section [res.on.exception.handling] states:

"An implementation may strengthen the exception-specification for a function by removing listed exceptions."

The problem is that if an implementation is allowed to do this for virtual functions, then a library user cannot write a class that portably derives from that class.

For example, this would not compile if ios_base::failure::~failure had an empty exception specification:

#include <ios>
#include <string>

class D : public std::ios_base::failure {
        D(const std::string&);
        ~D(); // error - exception specification must be compatible with 
              // overridden virtual function ios_base::failure::~failure()

Proposed resolution:

Change Section [res.on.exception.handling] from:

     "may strengthen the exception-specification for a function"


     "may strengthen the exception-specification for a non-virtual function".