Section: 17.9.5.4 [terminate] Status: NAD Submitter: Judy Ward Opened: 2001-04-03 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [terminate].
View all issues with NAD status.
Discussion:
According to section 18.7.3.3 of the standard, std::terminate() is supposed to call the terminate_handler in effect immediately after evaluating the throw expression.
Question: what if the terminate_handler in effect is itself std::terminate?
For example:
#include <exception> int main () { std::set_terminate(std::terminate); throw 5; return 0; }
Is the implementation allowed to go into an infinite loop?
I think the same issue applies to std::set_unexpected.
Proposed resolution:
Rationale:
Infinite recursion is to be expected: users who set the terminate
handler to terminate
are explicitly asking for terminate
to call itself.