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

2024-03-20


210. What is the type matched by an exception handler?

Section: 14.4  [except.handle]     Status: TC1     Submitter: Scott Douglass     Date: 6 Mar 2000

14.4 [except.handle] paragraph 3 says,

A handler is a match for a throw-expression with an object of type E...

This wording leaves it unclear whether it is the dynamic type of the object being thrown or the static type of the expression that determines whether a handler is a match for a given exception. For instance,

    struct B { B(); virtual ~B(); };
    struct D : B { D(); };
    void toss(const B* b) { throw *b; }
    void f() { const D d; toss(&d); }

In this code, presumably the type to be matched is B and not const D (14.2 [except.throw]).

Suggested resolution: Replace the cited wording as follows:

A handler is a match for a throw-expression which initialized a temporary (14.2 [except.throw]) of type E...

Proposed resolution (10/00):

  1. Change 14.2 [except.throw] paragraph 3 from

    A throw-expression initializes a temporary object, the type of which is determined...

    to

    A throw-expression initializes a temporary object, called the exception object, the type of which is determined...
  2. Change 14.4 [except.handle] paragraph 3 from

    A handler is a match for a throw-expression with an object of type E if...

    to

    A handler is a match for an exception object of type E if...