Date
2019-06-28.00:00:00
Message id
10470

Content

[res.on.exception.handling]#3 says:

Destructor operations defined in the C++ standard library shall not throw exceptions. Every destructor in the C++ standard library shall behave as if it had a non-throwing exception specification.

However, types like pair and array have implicitly declared destructors, where [except.spec]#8 applies:

The exception specification for an implicitly-declared destructor, or a destructor without a noexcept-specifier, is potentially-throwing if and only if any of the destructors for any of its potentially constructed subobjects is potentially-throwing or the destructor is virtual and the destructor of any virtual base class is potentially throwing.

We can relax [res.on.exception.handling] to only cover explicitly declared destructors because if they hold a user type where the destructor throws then we get UB from [res.on.functions]#2:

In particular, the effects are undefined in the following cases: […]

  1. […]

  2. (2.4) — if any replacement function or handler function or destructor operation exits via an exception, unless specifically allowed in the applicable Required behavior: paragraph.

  3. […]

and the referred to UB happens before [res.on.exception.handling] could apply.