Debian Codegraph @

gcc/testsuite/g++.dg/cpp1y/lambda-init8.C

raw
1 // DR1760: "no additional copy and destruction is performed"
2 // { dg-do run { target c++14 } }
3 // { dg-skip-if "requires hosted libstdc++ for cassert" { ! hostedlib } }
4
5 #include <cassert>
6
7 int copy_count = 0;
8 int dtor_count = 0;
9
10 struct X
11 {
12 X() = default;
13 X(const X&) { ++copy_count; }
14 ~X() { ++dtor_count; }
15 };
16
17 int main()
18 {
19 {
20 X x;
21 auto z = [y = x](){};
22 X x2;
23 auto z2 = [x2](){};
24 assert(copy_count == 2);
25 }
26 assert(dtor_count == 4);
27 }