[Bug c++/14026] New: std::uncaught_exception is true although there are no uncaught exceptions (rethrow, ghost exception)
hubert dot schmid at stud dot uka dot de
gcc-bugzilla@gcc.gnu.org
Thu Feb 5 10:54:00 GMT 2004
The following code shows the problem:
#include <iostream>
int main()
{
try {
throw 1;
} catch (...) {
try {
throw;
} catch (...) {
std::cout << std::uncaught_exception() << std::endl;
}
}
std::cout << std::uncaught_exception() << std::endl;
}
The program prints:
1
1
The expected output is:
0
0
Some detail: std::uncaught_exception() uses a variable (uncaughtExceptions),
that counts the number of uncaught exceptions. The value of this variable is -1
at the two print statements. I guess, this variable is incremented each time an
exception is thrown and decremented each time an exception is caught. I also
guess, that in the above program, the variable is possible not incremented at
the rethrow statement.
--
Summary: std::uncaught_exception is true although there are no
uncaught exceptions (rethrow, ghost exception)
Product: gcc
Version: 3.2.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: hubert dot schmid at stud dot uka dot de
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i386-pc-linux-gnu
GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14026
More information about the Gcc-bugs
mailing list