Title
Merging dynamic-exception-specifications and noexcept-specifications
Status
c++11
Section
14.5 [except.spec]
Submitter
Jason Merrill

Created on 2010-06-02.00:00:00 last changed 130 months ago

Messages

Date: 2011-03-15.00:00:00

[Voted into the WP at the March, 2011 meeting.]

Date: 2010-11-15.00:00:00

Proposed resolution (November, 2010):

  1. Change 14.5 [except.spec] paragraph 3 as follows:

  2. Two exception-specifications are compatible if:

    • both are non-throwing (see below), regardless of their form,

    • both have the form noexcept(constant-expression) and the constant-expressions are equivalent, or

    • one exception-specification is a noexcept-specification allowing all exceptions and the other is of the form throw(type-id-list), or

    • both are dynamic-exception-specifications that have the same set of adjusted types.

  3. Add the following note to the end of 14.5 [except.spec] paragraph 9:

  4. Whenever an exception is thrown and the search...

    end example]

    [Note: A function can have multiple declarations with different non-throwing exception-specifications; for this purpose, the one on the function definition is used. —end note]

Date: 2010-06-02.00:00:00

It is not clear how to handle compatible dynamic-exception-specifications and noexcept-specifications. For example, given

    void f() throw();
    void f() noexcept {
       throw 1;
    }

should we call terminate() or unexpected()? And for

    void g() throw (int);
    void g() noexcept (false) {
       throw 1.0;
    }

should this call unexpected or propagate the exception? Does the order of the declarations (and which is the definition) matter?

Alisdair Meredith:

And what about something like

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

What is the exception specification for C's destructor?

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: fdis -> c++11
2011-04-10 00:00:00adminsetmessages: + msg3407
2011-04-10 00:00:00adminsetstatus: ready -> fdis
2010-11-29 00:00:00adminsetmessages: + msg3062
2010-11-29 00:00:00adminsetstatus: drafting -> ready
2010-06-02 00:00:00admincreate