aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp2a/range-for10.C
blob: a0d0e6d085e7d04cddeff17984107c98eac3619a (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
// P0614R1
// { dg-do run }
// { dg-options "-std=c++2a" }

struct A { int i; long long j; } a[64];

int
main ()
{
  A b = { 1, 2 };
  for (auto & [ u, v ] : a)
    {
      u = 2;
      v = 3;
    }

  for (auto [x, y] = b; auto [ u, v ] : a)
    if (y + u != x + v)
      __builtin_abort ();

  for (auto [x, y] = b; auto & [ u, v ] : a)
    if (y + u != x + v)
      __builtin_abort ();
}