The description of uncaught_exception() throw() function states (18.6.4): Returns: true after completing evaluation of a throw-expression until either completing initialization of the exception-declaration in the matching handler or entering unexpected() due to the throw; or after entering terminate() for any reason other than an explicit call to terminate().
Apart from an explicit call to terminate() from the user's code, terminate() is called in the following situations (15.5.1): 1. When the exception handling mechanism, after completing evaluation of the expression to be thrown but before the exception is caught, calls a user function that exits via an uncaught exception. 2. When the exception handling mechanism cannot find a handler for a thrown exception. 3. When the destruction of an object during stack unwinding exits using an exception. 4. When construction or destruction of a non-local object with static storage duration exits using an exception. 5. When execution of a function registered with atexit exits using an exception. 6. When a throw-expression with no operand attempts to rethrow an exception and no exception is being handled. 7. When unexpected throws an exception which is not allowed by the previously violated exception specification, and std::bad_exception is not included in that exception-specification. However std::uncaught_exception called within a terminate_handler returns false in the cases 2,4,5,7 and true in the other cases (terminate_handler is specified using std::set_terminate()). The attached examples demonstrate the above 7 situations when terminate() is called "implicitly" and display the return value of std::uncaught_exception(). For example, reproducing situation 2: [EMAIL PROTECTED]:/mnt/hgfs/shared/temp/test$ g++ -Wall test2.cpp && ./a.out Exception will be thrown and it won't be catched. This situation meets the following condition when terminate should be called: 2.When the exception handling mechanism cannot find a handler for a thrown exception. Inside terminate_handler uncaught_exception() returns *false*. terminate called after throwing an instance of 'char const*' Aborted (core dumped) [EMAIL PROTECTED]:/mnt/hgfs/shared/temp/test$ g++ --version g++ (GCC) 4.1.2 (Ubuntu 4.1.2-0ubuntu4) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- Summary: std::uncaught_exception() returns wrong value after entering terminate() in some cases Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tsyvarev at ispras dot ru http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37477