Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to std::uncaught_exceptions #3214

Closed
wants to merge 1 commit into from

Conversation

singron
Copy link
Contributor

@singron singron commented Nov 8, 2019

This returns the number of uncaught exceptions. std::uncaught_exception
just returned whether there were any uncaught exceptions. c++17
deprecated it and c++20 will remove it. GCC 9 warns that the function is
deprecated.

std::uncaught_exceptions() can be > 1 if all exceptions are caught
before they propagate to a stack unwind. E.g. if a first exception
occurs and a destructor runs as part of the stack unwind, then that
destructor may cause additional exceptions to be thrown as long as they
are caught before that destructor returns.

I'm unsure if this can occur in nix, but I handled it by recording the
first count in the constructor and comparing it to the count in the
destructor. That way the object can determine whether the exception was
thrown during its lifetime.

This returns the number of uncaught exceptions. std::uncaught_exception
just returned whether there were any uncaught exceptions. c++17
deprecated it and c++20 will remove it. GCC 9 warns that the function is
deprecated.

std::uncaught_exceptions() can be > 1 if all exceptions are caught
before they propagate to a stack unwind. E.g. if a first exception
occurs and a destructor runs as part of the stack unwind, then that
destructor may cause additional exceptions to be thrown as long as they
are caught before that destructor returns.

I'm unsure if this can occur in nix, but I handled it by recording the
first count in the constructor and comparing it to the count in the
destructor. That way the object can determine whether the exception was
thrown during its lifetime.
@edolstra
Copy link
Member

See 93b1ce1.

@stale
Copy link

stale bot commented Feb 13, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Feb 13, 2021
@stale
Copy link

stale bot commented Apr 16, 2022

I closed this issue due to inactivity. → More info

@stale stale bot closed this Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants