Created on2013-09-25.00:00:00 last changed136 months ago
[Moved to DR at the February, 2014 meeting.]
Additional note, January, 2014:
The proposed resolution appears to have the undesirable implicationthat a special member function could become deleted after theclass is complete. For example, given
struct S { S() noexcept(false) = default; };we need to check that the explicit exception specificationis compatible with the one on the implicit declaration. Afterthe resolution ofissue 1330, theclass is regarded as complete withinexception-specifications,per 11.4 [class.mem] paragraph 2. This implies that theexplicitexception-specification can only be checked oncethe class is complete.
The issue has been returned to "review" status to allow discussionof this concern.
Proposed resolution (September, 2013):
Change 9.6.2 [dcl.fct.def.default] paragraphs 2 and 3 as follows:
An explicitly-defaulted function may be declaredconstexpr onlyif it would have been implicitly declared asconstexpr
, andmay have an explicitexception-specification only if it iscompatible (14.5 [except.spec]) withtheexception-specification on the implicit declaration. If afunction is explicitly defaulted on its first declaration,
it is implicitly considered to beconstexpr if theimplicit declaration would be, and,
it is implicitly considered to have thesameexception-specification as if it had been implicitly declared(14.5 [except.spec]).
If a function that is explicitly defaulted has anexplicitexception-specification that is not compatible(14.5 [except.spec]) with theexception-specification on theimplicit declaration, then
if the function is explicitly defaulted on its firstdeclaration, it is defined as deleted;
otherwise, the program is ill-formed.
[Example:
struct S { constexpr S() = default; // ill-formed: implicitS() is not constexpr S(int a = 0) = default; // ill-formed: default argument void operator=(const S&) = default; // ill-formed: non-matching return type ~S() throw(int) = default; //ill-formeddeleted: exception specification does not match private: int i; S(S&); // OK: private copy constructor }; S::S(S&) = default; // OK: defines copy constructor—end example]
According to 9.6.2 [dcl.fct.def.default] paragraph 2,
An explicitly-defaulted function may be declaredconstexpr only ifit would have been implicitly declared asconstexpr, and may have anexplicitexception-specification only if it is compatible(14.5 [except.spec]) with theexception-specification on theimplicit declaration.
The requirement forexception-specifications has unfortunateconsequences for the standard library componentatomic, asdescribedinLWGissue 2165: the component cannot be used with aTunlessT is nothrow default constructible, even ifthestd::atomic<T> variable is never defaultinitialized.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2014-11-24 00:00:00 | admin | set | status: dr -> c++14 |
| 2014-03-03 00:00:00 | admin | set | messages: +msg4951 |
| 2014-03-03 00:00:00 | admin | set | status: review -> dr |
| 2014-01-20 00:00:00 | admin | set | messages: +msg4743 |
| 2014-01-20 00:00:00 | admin | set | status: ready -> review |
| 2013-10-14 00:00:00 | admin | set | messages: +msg4592 |
| 2013-09-25 00:00:00 | admin | create | |