gcc/testsuite/g++.dg/cpp0x/lambda/lambda-ref3.C
raw| 1 | // { dg-do run { target c++11 } } |
| 2 | |
| 3 | int x; |
| 4 | int main() { |
| 5 | constexpr int&& r = static_cast<int&&>(x); |
| 6 | r = 1; |
| 7 | |
| 8 | auto a = [] { r = 2; }; // Not an ODR-use of 'r' so no capture needed. |
| 9 | auto b = [&] { r = 3; }; |
| 10 | |
| 11 | a(); |
| 12 | if (r != 2) |
| 13 | __builtin_abort(); |
| 14 | |
| 15 | b(); |
| 16 | if (r != 3) |
| 17 | __builtin_abort(); |
| 18 | } |