This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115d. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-10-26


1381. Implicitly-declared special member functions and default nothrow

Section: 14.5  [except.spec]     Status: CD3     Submitter: David Svoboda     Date: 2011-08-26

[Moved to DR at the October, 2012 meeting.]

According to 14.5 [except.spec] paragraph 14,

An implicitly declared special member function (11.4.4 [special]) shall have 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 all exceptions if any function it directly invokes allows all exceptions, and f shall allow no exceptions if every function it directly invokes allows no exceptions.

It would be clearer if this description made explicit the intent that special member functions that invoke no other functions are to allow no exceptions.

Proposed resolution (February, 2012):

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

...and f has the exception-specification noexcept(true) if every function it directly invokes allows no exceptions. [Note: It follows that f has the exception-specification noexcept(true) if it invokes no other functions. —end note] [Example:

  struct A {
    A();
    A(const A&) throw();
    A(A&&) throw();
    ~A() throw(X);
  };
  struct B {
    B() throw();
    B(const B&) throw() = default;  // Declaration of B::B(const B&) noexcept(true)
    B(B&&) throw(Y);
    ~B() throw(Y);
  };
  ...