view gcc/testsuite/g++.dg/cpp2a/range-for9.C @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +0900
parents 84e7813d76e9
children
line wrap: on
line source

// P0614R1
// { dg-do run }
// { dg-options "-std=c++2a" }

struct A { int i, j; };

int
main ()
{
  A a = { .i = 2, .j = 3 };
  int arr[] = { 1, 1, 1 };

  for (auto & [ x, y ] = a; auto z : arr)
    if (x + z != 3 || y + z != 4)
      __builtin_abort ();

  for (int d = 1; auto &z : arr)
    z += d;

  for (const auto [ x, y ] = a; auto z : arr)
    if (x + z != 4 || y + z != 5)
      __builtin_abort ();

  for (int d = 1; auto &z : arr)
    z += d;

  for (auto [ x, y ] = a; auto z : arr)
    if (x + z != 5 || y + z != 6)
      __builtin_abort ();
}