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