Rebase.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / lambda-init8.C
blob3a61b74eaedbd7bc20f236b6b4e7710b5ff443a4
1 // DR1760: "no additional copy and destruction is performed"
2 // { dg-do run { target c++1y } }
4 #include <cassert>
6 int copy_count = 0;
7 int dtor_count = 0;
9 struct X
11   X() = default;
12   X(const X&) { ++copy_count; }
13   ~X() { ++dtor_count; }
16 int main()
18   {
19     X x;
20     auto z = [y = x](){};
21     X x2;
22     auto z2 = [x2](){};
23     assert(copy_count == 2);
24   }
25   assert(dtor_count == 4);