aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp23/subscript9.C
blob: 72cea4b8cab6eecf309e1130cb870de0d43e9508 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// P2589R1
// { dg-do run { target c++23 } }

extern "C" void abort ();

struct S
{
  S () {};
  static int &operator[] () { return a[0]; }
  static int &operator[] (int x) { return a[x]; }
  static int &operator[] (int x, long y) { return a[x + y * 8]; }
  static int a[64];
};
int S::a[64];

int
main ()
{
  S s;
  for (int i = 0; i < 64; i++)
    s.a[i] = 64 - i;
  if (s[] != 64 || s[3] != 61 || s[4, 5] != 20)
    abort ();
  s[]++;
  s[42]++;
  ++s[3, 2];
  if (s.a[0] != 65 || s.a[42] != 23 || s.a[19] != 46)
    abort ();
}