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

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-02-10

Priority: Not Prioritized

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".