I have some clean up in a terminate_handler and it is possible to throw an exception. Do I need to worry about catching it to prevent recursive calls to the terminate_handler? With gcc, it seems this can’t happen and we just go into abort. Is that true of the standard or is the behavior undefined?
Share
A terminate handler is not allowed to return (§18.6.3.1/2); it must end the program (the default handler calls
abort()). If it consisted of:You’d get undefined behavior, because you would leave the function (because the exception propagates) without having terminated the program. So if you have code that could throw, make sure you catch all exceptions, like this:
However (to answer the title question), I don’t see anything that restricts it from being entered again, so this should be technically be fine: