Debian Codegraph @

gcc/testsuite/g++.dg/cpp1y/constexpr-77553.C

raw
1 // PR c++/77553
2 // { dg-do compile { target c++14 } }
3
4 constexpr void
5 bar (int *x)
6 {
7 int i = 0;
8 x[i++] = 1;
9 x[3] = i;
10 }
11
12 constexpr int
13 foo ()
14 {
15 int a[] = { 0, 0, 0, 0 };
16 bar (a);
17
18 return a[0] + 8 * a[1] + 64 * a[2] + 512 * a[3];
19 }
20
21 constexpr int b = foo ();
22
23 int
24 main ()
25 {
26 static_assert (b == 513, "");
27 if (foo () != 513)
28 __builtin_abort ();
29 }