| 1 |
// { dg-do run { xfail sparc64-*-elf arm-*-pe } } |
| 2 |
// { dg-options "-fexceptions" } |
| 3 |
|
| 4 |
#include <exception> |
| 5 |
#include <stdlib.h> |
| 6 |
|
| 7 |
struct double_fault { }; |
| 8 |
int fault_now; |
| 9 |
|
| 10 |
class E { |
| 11 |
public: |
| 12 |
E() { } |
| 13 |
E(const E&) { |
| 14 |
if (fault_now) |
| 15 |
throw double_fault(); |
| 16 |
} |
| 17 |
}; |
| 18 |
|
| 19 |
void foo() { |
| 20 |
try { |
| 21 |
throw E(); |
| 22 |
} catch (...) { |
| 23 |
fault_now = 1; |
| 24 |
throw; |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
void bar() { |
| 29 |
try { |
| 30 |
foo(); |
| 31 |
} catch (E e) { // double fault here |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
void my_terminate() { |
| 36 |
exit (0); // double faults should call terminate |
| 37 |
} |
| 38 |
|
| 39 |
int |
| 40 |
main() { |
| 41 |
std::set_terminate (my_terminate); |
| 42 |
try { |
| 43 |
bar(); |
| 44 |
} catch (...) { |
| 45 |
return 1; |
| 46 |
} |
| 47 |
return 1; |
| 48 |
} |