gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh.C
raw| 1 | // Test that we properly clean up if we get an exception in the middle of |
| 2 | // constructing the closure object. |
| 3 | |
| 4 | // { dg-do run } |
| 5 | // { dg-require-effective-target c++11 } |
| 6 | |
| 7 | struct A |
| 8 | { |
| 9 | A() {} |
| 10 | A(const A&) { throw 1; } |
| 11 | }; |
| 12 | |
| 13 | int bs; |
| 14 | struct B |
| 15 | { |
| 16 | B() { ++bs; } |
| 17 | B(const B&) { ++bs; } |
| 18 | ~B() { --bs; } |
| 19 | }; |
| 20 | |
| 21 | int main() |
| 22 | { |
| 23 | { |
| 24 | B b1, b2; |
| 25 | A a; |
| 26 | |
| 27 | try |
| 28 | { |
| 29 | [b1, a, b2]{ }; |
| 30 | } |
| 31 | catch(...) {} |
| 32 | } |
| 33 | return bs; |
| 34 | } |