@@ -48,10 +48,12 @@ __cxa_call_terminate(_Unwind_Exception* ue_header) throw ()
// exception. */
if (__is_gxx_exception_class(ue_header->exception_class))
{
- __cxa_exception* xh;
-
- xh = __get_exception_header_from_ue(ue_header);
- __terminate(xh->terminateHandler);
+ std::terminate_handler th;
+ if (__is_dependent_exception(ue_header->exception_class))
+ th = __get_dependent_exception_from_ue(ue_header)->terminateHandler;
+ else
+ th = __get_exception_header_from_ue(ue_header)->terminateHandler;
+ __terminate(th);
}
}
/* Call the global routine if we don't have anything better. */
@@ -737,20 +737,35 @@ __cxa_call_unexpected (void *exc_obj_in)
} end_catch_protect_obj;
lsda_header_info info;
- __cxa_exception *xh = __get_exception_header_from_ue (exc_obj);
const unsigned char *xh_lsda;
_Unwind_Sword xh_switch_value;
std::terminate_handler xh_terminate_handler;
-
+ std::unexpected_handler xh_unexpected_handler;
// If the unexpectedHandler rethrows the exception (e.g. to categorize it),
// it will clobber data about the current handler. So copy the data out now.
- xh_lsda = xh->languageSpecificData;
- xh_switch_value = xh->handlerSwitchValue;
- xh_terminate_handler = xh->terminateHandler;
- info.ttype_base = (_Unwind_Ptr) xh->catchTemp;
+ if (__is_dependent_exception(exc_obj->exception_class))
+ {
+ __cxa_dependent_exception *xh = __get_dependent_exception_from_ue (exc_obj);
+
+ xh_lsda = xh->languageSpecificData;
+ xh_switch_value = xh->handlerSwitchValue;
+ xh_terminate_handler = xh->terminateHandler;
+ xh_unexpected_handler = xh->unexpectedHandler;
+ info.ttype_base = (_Unwind_Ptr) xh->catchTemp;
+ }
+ else
+ {
+ __cxa_exception *xh = __get_exception_header_from_ue (exc_obj);
+
+ xh_lsda = xh->languageSpecificData;
+ xh_switch_value = xh->handlerSwitchValue;
+ xh_terminate_handler = xh->terminateHandler;
+ xh_unexpected_handler = xh->unexpectedHandler;
+ info.ttype_base = (_Unwind_Ptr) xh->catchTemp;
+ }
__try
- { __unexpected (xh->unexpectedHandler); }
+ { __unexpected (xh_unexpected_handler); }
__catch(...)
{
// Get the exception thrown from unexpected.
@@ -81,7 +81,7 @@ struct __cxa_exception
// Stack of exceptions in cleanups.
__cxa_exception* nextPropagatingException;
- // The nuber of active cleanup handlers for this exception.
+ // The number of active cleanup handlers for this exception.
int propagationCount;
#else
// Cache parsed handler data from the personality routine Phase 1
@@ -130,7 +130,7 @@ struct __cxa_dependent_exception
// Stack of exceptions in cleanups.
__cxa_exception* nextPropagatingException;
- // The nuber of active cleanup handlers for this exception.
+ // The number of active cleanup handlers for this exception.
int propagationCount;
#else
// Cache parsed handler data from the personality routine Phase 1
new file mode 100644
@@ -0,0 +1,41 @@
+// { dg-options "-std=gnu++11" }
+// { dg-require-atomic-builtins "" }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// PR libstdc++/60612
+
+#include <exception>
+#include <stdlib.h>
+
+void terminate() { _Exit(0); }
+
+void f() noexcept
+{
+ try {
+ throw 1;
+ } catch (...) {
+ std::set_terminate(terminate);
+ std::rethrow_exception(std::current_exception());
+ }
+}
+
+int main()
+{
+ f();
+}
new file mode 100644
@@ -0,0 +1,41 @@
+// { dg-options "-std=gnu++11" }
+// { dg-require-atomic-builtins "" }
+
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// PR libstdc++/60612
+
+#include <exception>
+#include <stdlib.h>
+
+void unexpected() { _Exit(0); }
+
+void f() throw()
+{
+ try {
+ throw 1;
+ } catch (...) {
+ std::set_unexpected(unexpected);
+ std::rethrow_exception(std::current_exception());
+ }
+}
+
+int main()
+{
+ f();
+}