1 // Make sure that we call terminate when a noexcept spec is violated.
2 // The function pointers are there to make sure that
3 // the compiler doesn't get clever about optimizing the calls based on
4 // knowledge about the called functions.
5 
6 // { dg-do run { target c++11 } }
7 
8 #include <exception>
9 #include <cstdlib>
10 
my_terminate()11 void my_terminate ()
12 {
13   std::exit (0);
14 }
15 
g()16 void g() { throw 1; }
17 void (*p1)() = g;
f()18 void f() noexcept { p1(); }
19 void (*p2)() = f;
h()20 void h() { p2(); }
21 
main()22 int main()
23 {
24   std::set_terminate (my_terminate);
25 
26   try { h(); }
27   catch (int) { }
28 
29   return 1;
30 }
31