Title
Should virtual functions be allowed to strengthen the exception specification?
Status
tc1
Section
[res.on.exception.handling]
Submitter
Judy Ward

Created on 1998-12-15.00:00:00 last changed 171 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

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

     "may strengthen the exception-specification for a function"

to:

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

Date: 1998-12-15.00:00:00

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 {
public:
        D(const std::string&);
        ~D(); // error - exception specification must be compatible with 
              // overridden virtual function ios_base::failure::~failure()
};
History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg1075
1998-12-15 00:00:00admincreate