| 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 |
|
| 11 |
void my_terminate () |
| 12 |
{ |
| 13 |
std::exit (0); |
| 14 |
} |
| 15 |
|
| 16 |
void g() { throw 1; } |
| 17 |
void (*p1)() = g; |
| 18 |
void f() noexcept { p1(); } |
| 19 |
void (*p2)() = f; |
| 20 |
void h() { p2(); } |
| 21 |
|
| 22 |
int main() |
| 23 |
{ |
| 24 |
std::set_terminate (my_terminate); |
| 25 |
|
| 26 |
try { h(); } |
| 27 |
catch (int) { } |
| 28 |
|
| 29 |
return 1; |
| 30 |
} |