summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.other/init7.C
blob: e6c7dc151f1be15619628dbb61a605338ce8439c (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
// { dg-do run  }
// simplified from testcase in Windows Developer Journal,
// submitted by eyal.ben-david@aks.com

// The initialization of a static local variable must be retried if a
// previous try finished by throwing an exception [stmt.dcl]/4

extern "C" void abort ();

struct foo {
  foo() { throw true; }
};

void bar() {
  static foo baz;
}

int main() {
  try {
    bar(); // must throw
  }
  catch (bool) {
    try {
      bar(); // must throw again!
    }
    catch (bool) {
      return 0;
    }
  }
  abort();
}