public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* 18_support/nested_exception/rethrow_if_nested-term.cc
@ 2023-08-20 10:08 Iain Sandoe
  2023-08-20 11:21 ` 18_support/nested_exception/rethrow_if_nested-term.cc Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Iain Sandoe @ 2023-08-20 10:08 UTC (permalink / raw)
  To: libstdc++

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-20 13:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-20 10:08 18_support/nested_exception/rethrow_if_nested-term.cc Iain Sandoe
2023-08-20 11:21 ` 18_support/nested_exception/rethrow_if_nested-term.cc Jonathan Wakely
2023-08-20 13:01   ` 18_support/nested_exception/rethrow_if_nested-term.cc Iain Sandoe
2023-08-20 13:33     ` 18_support/nested_exception/rethrow_if_nested-term.cc Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).