This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/41174] uncaught_exception always returns true
- From: "redi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Aug 2009 16:50:45 -0000
- Subject: [Bug c++/41174] uncaught_exception always returns true
- References: <bug-41174-18113@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from redi at gcc dot gnu dot org 2009-08-26 16:50 -------
I think the problem is that the uncaught_exception() is true as soon as the
memory for the exception has been allocated, but if the exception's copy
constructor is elided then happens before entering the exception's constructor.
If the exception constructor throws another exception then uncaughtExceptions
goes to 2, and never goes back to zero.
uncaught_exception() should return true after evaluating the operand of throw.
If the operand cannot be constructed (because it throws) then that evaluation
never completes.
My understanding is that this should run to completeion, but all four
assertions fail:
#include <cassert>
#include <exception>
struct e {
e()
{
assert( !std::uncaught_exception() );
try {
throw 1;
} catch (int i) {
assert( !std::uncaught_exception() );
throw;
}
}
};
int main()
{
try {
throw e();
} catch (int i) {
assert( !std::uncaught_exception() );
}
assert( !std::uncaught_exception() );
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41174