gcc/testsuite/g++.dg/eh/ref-temp3.C
raw| 1 | // { dg-do run } |
| 2 | |
| 3 | extern "C" void abort(); |
| 4 | |
| 5 | int a; |
| 6 | |
| 7 | struct A { |
| 8 | A() |
| 9 | { |
| 10 | if (a == 1) |
| 11 | throw 42; |
| 12 | ++a; |
| 13 | } |
| 14 | ~A() |
| 15 | { |
| 16 | --a; |
| 17 | } |
| 18 | }; |
| 19 | |
| 20 | struct B { |
| 21 | const A &a1; |
| 22 | const A &a2; |
| 23 | }; |
| 24 | |
| 25 | void f(); |
| 26 | |
| 27 | int main() |
| 28 | { |
| 29 | try |
| 30 | { |
| 31 | B b = { A(), A() }; |
| 32 | } |
| 33 | catch (...) { } |
| 34 | if (a != 0) |
| 35 | abort (); |
| 36 | } |