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:
E()12   E() { }
E(const E &)13   E(const E&) {
14     if (fault_now)
15       throw double_fault();
16   }
17 };
18 
foo()19 void foo() {
20   try {
21     throw E();
22   } catch (...) {
23     fault_now = 1;
24     throw;
25   }
26 }
27 
bar()28 void bar() {
29   try {
30     foo();
31   } catch (E e) {	// double fault here
32   }
33 }
34 
my_terminate()35 void my_terminate() {
36   exit (0);		// double faults should call terminate
37 }
38 
main()39 main() {
40   std::set_terminate (my_terminate);
41   try {
42     bar();
43   } catch (...) {
44     return 1;
45   }
46   return 1;
47 }
48