[PR c++/84702] ICE with default tmpl arg of overload set
[official-gcc.git] / gcc / testsuite / g++.dg / eh / forced3.C
blob9e92dafb08f96957dae33588cf5a1c6cb66da8f0
1 // HP-UX libunwind.so doesn't provide _UA_END_OF_STACK.
2 // { dg-do run { xfail "ia64-hp-hpux11.*" } }
3 // { dg-require-effective-target c++14_down }
5 // Test that forced unwinding calls std::unexpected going 
6 // through a nothrow function.
8 #include <unwind.h>
9 #include <stdlib.h>
10 #include <exception>
11 #include <string.h>
13 static _Unwind_Reason_Code
14 force_unwind_stop (int version, _Unwind_Action actions,
15                    _Unwind_Exception_Class exc_class,
16                    struct _Unwind_Exception *exc_obj,
17                    struct _Unwind_Context *context,
18                    void *stop_parameter)
20   if (actions & _UA_END_OF_STACK)
21     abort ();
22   return _URC_NO_REASON;
25 static void __attribute__((noreturn))
26 force_unwind ()
28   _Unwind_Exception *exc = new _Unwind_Exception;
29   // exception_class might not be a scalar.
30   memset (&exc->exception_class, 0, sizeof (exc->exception_class));
31   exc->exception_cleanup = 0;
33 #ifndef __USING_SJLJ_EXCEPTIONS__
34   _Unwind_ForcedUnwind (exc, force_unwind_stop, 0);
35 #else
36   _Unwind_SjLj_ForcedUnwind (exc, force_unwind_stop, 0);
37 #endif
39   abort ();
42 static void
43 handle_unexpected ()
45   exit (0);
48 static void
49 doit () throw()
51   force_unwind ();
54 int main()
55
56   std::set_unexpected (handle_unexpected);
57   doit ();
58   abort ();