2018-10-23 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / eh / spec10.C
bloba62d24e663ac6ca29efe162e759f932dbe86a1df
1 // Make sure that we call terminate when a throw() spec is violated even
2 // with -fnothrow-opt.  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.
6 // { dg-options "-fnothrow-opt" }
7 // { dg-do run }
9 #include <exception>
10 #include <cstdlib>
12 void my_terminate ()
14   std::exit (0);
17 void g() { throw 1; }
18 void (*p1)() = g;
19 void f() throw() { p1(); }
20 void (*p2)() = f;
21 void h() { p2(); }
23 int main()
25   std::set_terminate (my_terminate);
27   try { h(); }
28   catch (int) { }
30   return 1;