PR c++/56973, DR 696 - capture constant variables only as needed.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / constexpr-loop4.C
blob67f7cfa1d1d689e794633c40c197ba9d8b18c884
1 // { dg-do compile { target c++14 } }
3 struct A
5   int i;
6 };
8 constexpr bool f()
10   A ar[5] = { 6, 7, 8, 9, 10 };
11   A *ap = ar;
12   int i = 0, j = 0;
13   for (j = 0; j < 2; j++)
14     {
15       do
16         *ap++ = A{i};
17       while (++i < j * 2 + 2);
18     }
19   return (ar[0].i == 0
20           && ar[1].i == 1
21           && ar[2].i == 2
22           && ar[3].i == 3
23           && ar[4].i == 10);
26 #define SA(X) static_assert((X),#X)
27 SA(f());