PR c++/56973, DR 696 - capture constant variables only as needed.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / lambda-init4.C
blob787ffc0476d6d8e96409703802d20b137a58966a
1 // N3648: capture init example from paper
2 // { dg-do run { target c++14 } }
4 int x = 4;
5 auto y = [&r = x, x = x+1]()->int {
6   r += 2;
7   return x+2;
8 }();  // Updates ::x to 6, and initializes y to 7.
10 int main()
12   if (x != 6 || y != 7) __builtin_abort();