gcc/testsuite/g++.dg/cpp0x/lambda/lambda-return1.C
raw| 1 | // PR c++/57437 |
| 2 | // { dg-do run } */ |
| 3 | // { dg-require-effective-target c++11 } |
| 4 | |
| 5 | struct A { |
| 6 | int i; |
| 7 | |
| 8 | A(): i(42) {} |
| 9 | A(const A&) = default; |
| 10 | A(A&& a): i(a.i) { a.i = 0; } |
| 11 | }; |
| 12 | |
| 13 | int main() |
| 14 | { |
| 15 | A x; |
| 16 | |
| 17 | auto y = [x] () mutable { |
| 18 | x.i++; |
| 19 | return x; |
| 20 | }; |
| 21 | |
| 22 | if (y().i != 43) |
| 23 | __builtin_abort (); |
| 24 | |
| 25 | if (y().i != 44) |
| 26 | __builtin_abort (); |
| 27 | } |