Created on 2007-06-06.00:00:00 last changed 162 months ago
Proposed resolution:
Change around [except.nested] p.4 as indicated:
-4- Throws: the stored exception captured by this nested_exception object, if nested_ptr() != nullptr
- Remarks: If nested_ptr() == nullptr, terminate() shall be called.
[ 2009 Santa Cruz: ]
Move to Ready.
It was recently mentioned in a newsgroup article http://groups.google.de/group/comp.std.c++/msg/f82022aff68edf3d that the specification of the member function rethrow_nested() of the class nested_exception is incomplete, specifically it remains unclear what happens, if member nested_ptr() returns a null value. In [except.nested] we find only the following paragraph related to that:
void rethrow_nested() const; // [[noreturn]]-4- Throws: the stored exception captured by this nested_exception object.
This is a problem, because it is possible to create an object of nested_exception with exactly such a state, e.g.
#include <exception> #include <iostream> int main() try { std::nested_exception e; // OK, calls current_exception() and stores it's null value e.rethrow_nested(); // ? std::cout << "A" << std::endl; } catch(...) { std::cout << "B" << std::endl; }
I suggest to follow the proposal of the reporter, namely to invoke terminate() if nested_ptr() return a null value of exception_ptr instead of relying on the fallback position of undefined behavior. This would be consistent to the behavior of a throw; statement when no exception is being handled.
History | |||
---|---|---|---|
Date | User | Action | Args |
2011-08-23 20:07:26 | admin | set | status: wp -> c++11 |
2010-10-21 18:28:33 | admin | set | messages: + msg882 |
2010-10-21 18:28:33 | admin | set | messages: + msg881 |
2007-06-06 00:00:00 | admin | create |