This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/61643] New: [C++11] std::uncaught_exception returns wrong values after std::rethrow_if_nested
- From: "ai.azuma at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 29 Jun 2014 05:55:10 +0000
- Subject: [Bug libstdc++/61643] New: [C++11] std::uncaught_exception returns wrong values after std::rethrow_if_nested
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61643
Bug ID: 61643
Summary: [C++11] std::uncaught_exception returns wrong values
after std::rethrow_if_nested
Product: gcc
Version: 4.10.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: ai.azuma at gmail dot com
The following program should terminate successfully.
//=========================================================
#include <stdexcept>
#include <exception>
#include <cstdlib>
struct X
{
~X() {
if (!std::uncaught_exception()) std::abort(); // (A)
}
};
int main() {
try {
throw std::runtime_error("");
}
catch (...) {
try {
std::throw_with_nested(std::runtime_error(""));
}
catch (std::runtime_error const &e) {
try {
X x;
std::rethrow_if_nested(e);
}
catch (std::runtime_error const &e) {
if (std::uncaught_exception()) std::abort(); // (B)
}
}
}
return EXIT_SUCCESS;
}
//=========================================================
However, the program is aborted at the line marked with `(A)', and at the line
marked with `(B)' if the line marked with `(A)' is commented out.
This problem is reproduced with 4.10.0 20140622, 4.9.1 20140625 and 4.8.4
20140619. The reproducer requires -std=c++11 flag to compile.