gcc/testsuite/g++.dg/cpp0x/lambda/lambda-mutable2.C
raw| 1 | // PR c++/55532 |
| 2 | // { dg-do compile { target c++11 } } |
| 3 | |
| 4 | struct Foo { |
| 5 | void doit() { |
| 6 | } |
| 7 | }; |
| 8 | |
| 9 | template<typename T> |
| 10 | void oops(Foo &foo, const T &) { |
| 11 | auto fun = [&] () mutable { |
| 12 | foo.doit(); |
| 13 | }; |
| 14 | auto fun2 = [=]() { |
| 15 | fun(); // { dg-error "" } |
| 16 | }; |
| 17 | fun2(); |
| 18 | } |
| 19 | |
| 20 | int main() { |
| 21 | Foo foo; |
| 22 | oops(foo, 1); |
| 23 | } |