Skip to content

std::uncaught_exception flag not reset properly #4392

Closed
@haukeduden

Description

@haukeduden

When an exception is re-thrown and re-caught inside a catch handler then the std::uncaught_exception flag remains set indefinitely. This is a bug, as there is not actually an uncaught active exception at that point.

This is a problem for some unittest frameworks (like the Catch framework), which re-throw exceptions that occur during a test to determine the exception type. This bug is a showstopper for using these frameworks.

I have tested this with version 1.36.5 (current "incoming" branch).

The following code reproduces the bug:

#include <iostream>
#include <exception>

int main()
{   
    try
    {       
        throw std::exception();
    }
    catch(std::exception)
    {
        try
        {
            throw;
        }
        catch(std::exception)
        {

        }
    }

    if(std::uncaught_exception())
        std::cout << "ERROR: uncaught_exception still set.";
    else
        std::cout << "OK";

   return 0;

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions