Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/lambda/lambda-conv13.C

raw
1 // PR c++/86943
2 // { dg-do run { target c++14 } }
3
4 int c[3];
5
6 struct S
7 {
8 S () : s (1234) { c[0]++; }
9 S (const S &) { __builtin_abort (); }
10 S (S &&x) noexcept { if (x.s != 1234) __builtin_abort (); s = 1234; x.s = 2345; c[1]++; }
11 ~S () { if (s != 1234 && s != 2345) __builtin_abort (); c[2]++; }
12 int s;
13 };
14
15 using F = S (*) (S);
16
17 F
18 foo ()
19 {
20 return [] (auto val)->S { if (val.s != 1234) __builtin_abort (); return {}; };
21 }
22
23 int
24 main ()
25 {
26 {
27 volatile F f = foo ();
28 S s = f ({});
29 if (s.s != 1234) __builtin_abort ();
30 }
31 if (c[0] + c[1] != c[2])
32 __builtin_abort ();
33 }