3 // { dg-options "-std=c++23" }
5 extern "C" void abort ();
9 constexpr S () : a {} {};
10 constexpr S (int x, int y, int z) : a {x, y, z} {};
11 constexpr int &operator[] () { return a[0]; }
12 constexpr int &operator[] (int x) { return a[x]; }
13 constexpr int &operator[] (int x, long y) { return a[x + y * 8]; }
19 operator int () { return 42; };
26 operator int * () { return buf; }
33 static_assert (S ()[1] == 0);
34 static_assert (S (1, 2, 42)[2] == 42);
35 static_assert (S ()[3, 4] == 0);
36 static_assert (S (1, 43, 2)[1, 0] == 43);
37 static_assert (S ()[] == 0);
38 static_assert (S (44, 1, 2)[] == 44);
40 for (int i = 0; i < 64; i++)
42 if (s[] != 64 || s[3] != 61 || s[4, 5] != 20)
47 if (s.a[0] != 65 || s.a[42] != 23 || s.a[19] != 46)
51 if (&u[t] != &buf[42])
53 if (&t[u] != &buf[42])
57 template <typename V, typename W, typename X>
61 static_assert (V ()[1] == 0);
62 static_assert (V (1, 2, 42)[2] == 42);
63 static_assert (V ()[3, 4] == 0);
64 static_assert (V (1, 43, 2)[1, 0] == 43);
65 static_assert (V ()[] == 0);
66 static_assert (V (44, 1, 2)[] == 44);
68 for (int i = 0; i < 64; i++)
70 if (s[] != 64 || s[3] != 61 || s[4, 5] != 20)
75 if (s.a[0] != 65 || s.a[42] != 23 || s.a[19] != 46)
79 if (&u[t] != &buf[42])
81 if (&t[u] != &buf[42])