Namespaces
Variants
Views
Actions

Talk:cpp/error/uncaught exception

From cppreference.com

The description states that "Sometimes it's safe to throw an exception even while std::uncaught_exception() == true", but the example - "if exceptions are caught and ignored in a destructor, they can't propagate out of it and won't lead to std::terminate" - doesn't seem to relate to the assertion. Is it unclear or unrelated? 92.235.157.64 13:40, 22 November 2012 (PST)

It's exactly the case when it is safe: suppose stack unwinding is in progress and a destructor of some local object is called. In the body of that destructor, there is a call to a potentially throwing function, surrounded in a try/catch(...). The destructor calls that potentially-throwing function, and inside that function, uncaught_exception() == true, but it's safe to throw. I suppose it's unclear, tried to edit for clarity. --Cubbi 19:16, 22 November 2012 (PST)
Ahh yes, didn't think of being inside a try..catch in a destructor during stack unwinding. Silly brain. Thanks for the edit - clarification works fine. 92.235.157.64 15:47, 24 November 2012 (PST)