Title
Underspecified destructor exception-specification
Status
cd3
Section
14.5 [except.spec]
Submitter
Daniel Krügler

Created on 2011-03-28.00:00:00 last changed 123 months ago

Messages

Date: 2012-02-15.00:00:00

[Voted into the WP at the February, 2012 meeting; moved to DR at the October, 2012 meeting.]

Date: 2011-08-15.00:00:00

Proposed resolution (August, 2011):

Change 14.5 [except.spec] paragraph 14 as follows:

An implicitly declared special member function (11.4.4 [special]) shall have has an exception-specification. If f is an implicitly declared default constructor, copy constructor, move constructor, destructor, copy assignment operator, or move assignment operator, its implicit exception-specification specifies the type-id T if and only if T is allowed by the exception-specification of a function directly invoked by f's implicit definition; f shall allow allows all exceptions if any function it directly invokes allows all exceptions, and f shall allow no exceptions has the exception-specification noexcept(true) if every function it directly invokes allows no exceptions. [Example:

  struct A {
    A();
    A(const A&) throw();
    A(A&&) throw();
    ~A() throw(X);
  };
  struct B {
    B() throw();
    B(const B&) throw();
    B(B&&) throw(Y);
    ~B() throw(Y);
  };
  struct D : public A, public B {
      // Implicit declaration of D::D();
      // Implicit declaration of D::D(const D&) throw() noexcept(true);
      // Implicit declaration of D::D(D&&) throw(Y);
      // Implicit declaration of D::~D() throw(X, Y);
  };

Furthermore, if...

Date: 2012-09-24.00:00:00

It is not clear whether the unexpected handler will be invoked in the following example:

  #include <iostream>
  #include <exception>

  struct A { ~A() throw() { } };
  struct B { ~B() noexcept { } };
  struct C : A, B { ~C() { throw 0; } };

  void unexpected_observer() {
   std::cerr << "unexpected called" << std::endl;
   std::terminate();
  }

  int main() {
   std::set_unexpected(unexpected_observer);
   C c;
  }

The problem is 14.5 [except.spec] paragraph 14 only says that the exception-specification of C::~C “shall allow no exceptions,” which could mean either throw() or noexcept(true).

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2012-11-03 00:00:00adminsetstatus: dr -> drwp
2012-09-24 00:00:00adminsetmessages: + msg4015
2012-02-27 00:00:00adminsetmessages: + msg3836
2012-02-27 00:00:00adminsetstatus: ready -> dr
2011-03-28 00:00:00admincreate