view gcc/testsuite/g++.dg/cpp1y/vla4.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

// Test for range-based for with VLAs.
// { dg-do run { target c++11 } }
// { dg-options "-Wno-vla" }

#include <new>

void f(int i)
{
  int ar[i];
  int j = 0;
  for (int& x : ar)
    x = ++j;
  [&ar]{
    int k = 0;
    for (int x : ar)
      if (x != ++k)
	__builtin_abort();
  }();
}

int main()
{
  f(42);				// OK
}