------- 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

Reply via email to