18_support/nested_exception/rethrow_if_nested-term.cc
Iain Sandoe
iain@sandoe.co.uk
Sun Aug 20 10:08:23 GMT 2023
Hi
I’ve been trying to figure out why the test from $SUBJECT fails when I use the c++abi library (either with clang or g++ and a modified libstdc++ that uses c++abi for it’s runtime support).
At the moment, I am not sure where exactly the issue lies - but I suspect it might be in implementation divergence over the set_terminate call.
The issue seems to center around interpretation of the following statement in the upstream cxxabi:
" • The fields unexpectedHandler and terminateHandler contain pointers to the unexpected and terminate handlers at the point where the exception is thrown. The ISO C++ Final Draft International Standard [lib.unexpected] (18.6.2.4) states that the handlers to be used are those active immediately after evaluating the throw argument. If destructors change the active handlers during unwinding, the new values are not used until unwinding is complete.”
- but I cannot find that statement in the current C++ draft, instead it seems to say:
"It is unspecified which terminate_handler function will be called if an exception is active during a call to set_terminate. Otherwise calls the current terminate_handler function.” (https://eel.is/c++draft/support.exception#terminate).
—
If I set the terminate handler before the throw, then the c++abi implementation works the same as the supc++ one.
For both runtime support libraries, if I inspect the current exception from the terminate handler it shows we have a _nested<A> .
So, ISTM that the difference is not in the actual nested exception handling (including the conditional rethrow) but lies, instead in a different interpretation of when the changes from set_terminate() take effect.
— it needs someone with state on the history of this to comment …
a) does that seem like a reasonable analysis?
b) would it be acceptable to move the set_terminate () call?
- I can also make changes conditional on the support runtime - but trying to minimise those.
thanks
Iain
More information about the Libstdc++
mailing list