summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.mike/eh23.C
blob: da2ac0ef39d94c79da314a6b7396491c83c5b663 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// { dg-do run { xfail sparc64-*-elf arm-*-pe } }
// { dg-options "-fexceptions" }

#include <exception>
#include <stdlib.h>

struct double_fault { };
int fault_now;

class E {
public:
  E() { }
  E(const E&) {
    if (fault_now)
      throw double_fault();
  }
};

void foo() {
  try {
    throw E();
  } catch (...) {
    fault_now = 1;
    throw;
  }
}

void bar() {
  try {
    foo();
  } catch (E e) {	// double fault here
  }
}

void my_terminate() {
  exit (0);		// double faults should call terminate
}

main() {
  std::set_terminate (my_terminate);
  try {
    bar();
  } catch (...) {
    return 1;
  }
  return 1;
}