Title
exception-specifications and defaulted special member functions
Status
cd4
Section
9.5.2 [dcl.fct.def.default]
Submitter
Daveed Vandevoorde

Created on 2012-09-07.00:00:00 last changed 94 months ago

Messages

Date: 2014-11-15.00:00:00

[Moved to DR at the November, 2014 meeting.]

Date: 2014-02-15.00:00:00

Additional note (February, 2014):

The overloads cited in the preceding note have been independently changed in N3936 to include a noexcept specification, making the proposed resolution correct as it stands.

Date: 2013-01-15.00:00:00

Additional note (January, 2013):

The resolution conflicts with the current specification of operator delete: in 6.7.5.5 [basic.stc.dynamic] paragraph 2, the two operator delete overloads are declared with an implicit exception specification, while in 17.6 [support.dynamic] paragraph 1, they are declared as noexcept.

Date: 2014-02-15.00:00:00

Proposed resolution (February, 2014):

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

...If any declaration of a pointer to function, reference to function, or pointer to member function has an exception-specification, all occurrences of that declaration shall have a compatible exception-specification. If a declaration of a function has an implicit exception-specification, other declarations of the function shall not specify an exception-specification. In an explicit instantiation...

(This resolution also resolves issue 1492.)

Date: 2012-09-07.00:00:00

The current wording of 9.5.2 [dcl.fct.def.default] paragraph 2 has some surprising implications:

An explicitly-defaulted function may be declared constexpr only if it would have been implicitly declared as constexpr, and may have an explicit exception-specification only if it is compatible (14.5 [except.spec]) with the exception-specification on the implicit declaration.

In an example like

  struct A {
    A& operator=(A&);
  };
  A& A::operator=(A&) = default;

presumably the exception-specification of A::operator=(A&) is noexcept(false). However, attempting to make that exception-specification explicit,

  A& A::operator=(A&) noexcept(false) = default;

is an error. Is this intentional?

History
Date User Action Args
2017-02-06 00:00:00adminsetstatus: drwp -> cd4
2015-05-25 00:00:00adminsetstatus: dr -> drwp
2015-04-13 00:00:00adminsetmessages: + msg5378
2014-11-24 00:00:00adminsetstatus: ready -> dr
2014-03-03 00:00:00adminsetmessages: + msg4832
2014-03-03 00:00:00adminsetstatus: drafting -> ready
2013-05-03 00:00:00adminsetstatus: review -> drafting
2013-01-14 00:00:00adminsetmessages: + msg4201
2013-01-14 00:00:00adminsetstatus: tentatively ready -> review
2012-11-03 00:00:00adminsetmessages: + msg4074
2012-11-03 00:00:00adminsetstatus: open -> tentatively ready
2012-09-07 00:00:00admincreate