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

2024-11-11


1073. Merging dynamic-exception-specifications and noexcept-specifications

Section: 14.5  [except.spec]     Status: C++11     Submitter: Jason Merrill     Date: 2010-06-02

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

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?

Proposed resolution (November, 2010):

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

  2. Two exception-specifications are compatible if:

  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]