gcc/testsuite/g++.dg/eh/aggregate2.C
raw| 1 | // PR c++/96876 |
| 2 | // { dg-do run { target c++11 } } |
| 3 | |
| 4 | int d; |
| 5 | struct B { |
| 6 | ~B() { ++d; } |
| 7 | }; |
| 8 | |
| 9 | struct C1 { B b; int n; }; |
| 10 | struct C2 { int i; B b; int n; }; |
| 11 | |
| 12 | int f() { throw 24; return 42; } |
| 13 | int dummy; |
| 14 | int g() { ++dummy; return 42; } |
| 15 | |
| 16 | int main() { |
| 17 | try { |
| 18 | C1 c{{}, f()}; |
| 19 | } catch (...) { } |
| 20 | |
| 21 | try { |
| 22 | C2 c{g(), {}, f()}; |
| 23 | } catch (...) { } |
| 24 | |
| 25 | if (d != 2) |
| 26 | __builtin_abort (); |
| 27 | } |