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

2023-02-07


1168. Additional reasons to call std::terminate

Section: 14.6.2  [except.terminate]     Status: C++11     Submitter: GB     Date: 2010-08-03

[Voted into the WP at the November, 2010 meeting.]

N3092 comment GB 47

The list of reasons for which std::terminate is called needs to be extended to cover several additional cases in C++0x:

Proposed resolution (August, 2010):

  1. Change 14.6.2 [except.terminate] paragraph 1 as follows:

  2. In the following some situations exception handling must be abandoned for less subtle error handling techniques:. [Note: These situations are:

    end note]

  3. Insert the following as a new paragraph following 14.2 [except.throw] paragraph 6:

  4. An exception is considered caught...

    If the exception handling mechanism, after completing evaluation of the expression to be thrown but before the exception is caught, calls a function that exits via an exception, std::terminate is called (14.6.2 [except.terminate]). [Example:

        struct C {
          C() { }
          C(const C&) { throw 0; }
        };
    
        int main() {
          try {
            throw C();   // calls std::terminate()
          } catch(C) { }
        }
    

    end example]

  5. Change 14.3 [except.ctor] paragraph 3 as follows:

  6. The process of calling destructors for automatic objects constructed on the path from a try block to a throw-expression is called “stack unwinding.” [Note: If a destructor called during stack unwinding exits with an exception, std::terminate is called (14.6.2 [except.terminate]). [Note: So destructors should generally catch exceptions and not let them propagate out of the destructor. —end note]
  7. Change 6.9.3.2 [basic.start.static] paragraph 6 as follows:

  8. [Note: If the initialization of a non-local variable with static or thread storage duration terminates by throwing exits via an exception, std::terminate is called (see 14.6.2 [except.terminate]). end note]
  9. Change 6.9.3.3 [basic.start.dynamic] paragraph 1 as follows:

  10. ...[Note: If the destruction of a non-local an object with static or thread storage duration terminates by throwing exits via an exception, std::terminate is called (see 14.6.2 [except.terminate]). end note]
  11. Change 17.5 [support.start.term] bullet 8.1 as follows: