diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh.C')
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh.C | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh.C new file mode 100644 index 000000000..ea5060d1a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh.C @@ -0,0 +1,35 @@ +// Test that we properly clean up if we get an exception in the middle of +// constructing the closure object. +// { dg-options -std=c++0x } + +// This test fails because of PR 41449; it isn't a lambda issue. +// { dg-do run { xfail *-*-* } } + +struct A +{ + A() {} + A(const A&) { throw 1; } +}; + +int bs; +struct B +{ + B() { ++bs; } + B(const B&) { ++bs; } + ~B() { --bs; } +}; + +int main() +{ + { + B b1, b2; + A a; + + try + { + [b1, a, b2]{ }; + } + catch(...) {} + } + return bs; +} |