1 // DR1760: "no additional copy and destruction is performed" 2 // { dg-do run { target c++14 } } 3 4 #include <cassert> 5 6 int copy_count = 0; 7 int dtor_count = 0; 8 9 struct X 10 { 11 X() = default; XX12 X(const X&) { ++copy_count; } ~XX13 ~X() { ++dtor_count; } 14 }; 15 main()16int main() 17 { 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); 26 } 27