| 1 |
// PR c++/108437 |
| 2 |
// { dg-do run { target c++23 } } |
| 3 |
|
| 4 |
struct S { static int &operator[] (int x) { static int a[2]; return a[x]; } }; |
| 5 |
struct U { static int &operator[] (int x, int y, int z) { static int a[2]; return a[x + y + z]; } }; |
| 6 |
struct V { static int &operator[] () { static int a; return a; } }; |
| 7 |
|
| 8 |
template <class T, class W, class X> void |
| 9 |
foo () |
| 10 |
{ |
| 11 |
S s; |
| 12 |
s[0]++; |
| 13 |
T t; |
| 14 |
t[0]++; |
| 15 |
U u; |
| 16 |
u[0, 0, 0]++; |
| 17 |
V v; |
| 18 |
v[]++; |
| 19 |
W w; |
| 20 |
w[0, 0, 0]++; |
| 21 |
X x; |
| 22 |
x[]++; |
| 23 |
} |
| 24 |
|
| 25 |
int |
| 26 |
main () |
| 27 |
{ |
| 28 |
S::operator[] (0) = 1; |
| 29 |
U::operator[] (0, 0, 0) = 2; |
| 30 |
V::operator[] () = 3; |
| 31 |
foo <S, U, V> (); |
| 32 |
if (S::operator[] (0) != 3 || U::operator[] (0, 0, 0) != 4 || V::operator[] () != 5) |
| 33 |
__builtin_abort (); |
| 34 |
} |