| 1 |
// PR c++/97720 |
| 2 |
// { dg-do run } |
| 3 |
|
| 4 |
// Test that there is an active exception when we reach the terminate handler. |
| 5 |
|
| 6 |
#include <exception> |
| 7 |
#include <cstdlib> |
| 8 |
|
| 9 |
void bad_guy() throw() { |
| 10 |
try { throw 0; } |
| 11 |
catch (float) { } |
| 12 |
// Don't catch int. |
| 13 |
} |
| 14 |
|
| 15 |
void level1() { |
| 16 |
bad_guy(); |
| 17 |
throw "dead code"; |
| 18 |
} |
| 19 |
|
| 20 |
void my_term() |
| 21 |
{ |
| 22 |
try { throw; } |
| 23 |
catch(...) { std::exit(0); } |
| 24 |
} |
| 25 |
|
| 26 |
int main() { |
| 27 |
std::set_terminate (my_term); |
| 28 |
try { level1(); } |
| 29 |
catch (int) { } |
| 30 |
} |