aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-eh.C
blob: 7516fe0fe01369f142829e21d5fa00a4dc81a775 (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
32
33
34
35
// Test that we properly clean up if we get an exception in the middle of
// constructing the closure object.

// This test fails because of PR 41449; it isn't a lambda issue.
// { dg-do run { xfail *-*-* } }
// { dg-require-effective-target c++11 }

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;
}