This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/14026] New: std::uncaught_exception is true although there are no uncaught exceptions (rethrow, ghost exception)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]