http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59224
Bug ID: 59224 Summary: std::uncaught_exception always returns true after exception while constructing another exception. Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: man2gm at gmail dot com This code prints (erroneously) Hello, world! 1 in g++ 4.8.1, g++ 4.6.3, but works correctly in g++ 4.5.2. cat main.cpp #include <string> #include <iostream> struct Exception { std::string what; Exception(const std::string & what_) : what(what_) {} }; std::string f() { throw Exception("Hello, world!"); } void g() { try { f(); } catch (...) { throw Exception(f()); } } int main(int argc, char ** argv) { try { g(); } catch (const Exception & e) { std::cerr << e.what << std::endl; } /// returns 1 in gcc 4.6.3, 4.8.1 - bug std::cerr << std::uncaught_exception() << std::endl; return 0; } # g++-4.8 --version g++-4.8 (Ubuntu 4.8.1-2ubuntu1~12.04) 4.8.1 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # g++-4.8 main.cpp # ./a.out Hello, world! 1 # g++-4.6 --version g++-4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Copyright (C) 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # g++-4.6 main.cpp # ./a.out Hello, world! 1 # g++-4.5 --version g++-4.5 (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2 Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # g++-4.5 main.cpp # ./a.out Hello, world! 0 http://ideone.com/lx2ao2