1 // PR c++/89336
2 // { dg-do compile { target c++14 } }
3 
4 template <typename T, int N> struct A {
5   T a[N];
6   constexpr T &operator[] (int x) { return a[x]; }
7   constexpr const T &operator[] (int x) const { return a[x]; }
8 };
9 
10 constexpr A<int, 16>
foo()11 foo ()
12 {
13   A<int, 16> r{};
14   for (int i = 0; i < 6; ++i)
15     r[i + 8] = r[i] = i + 1;
16   return r;
17 }
18 
19 constexpr auto x = foo ();
20 static_assert (x[0] == 1, "");
21 static_assert (x[1] == 2, "");
22 static_assert (x[2] == 3, "");
23 static_assert (x[3] == 4, "");
24 static_assert (x[4] == 5, "");
25 static_assert (x[5] == 6, "");
26 static_assert (x[6] == 0, "");
27 static_assert (x[7] == 0, "");
28 static_assert (x[8] == 1, "");
29 static_assert (x[9] == 2, "");
30 static_assert (x[10] == 3, "");
31 static_assert (x[11] == 4, "");
32 static_assert (x[12] == 5, "");
33 static_assert (x[13] == 6, "");
34 static_assert (x[14] == 0, "");
35 static_assert (x[15] == 0, "");
36