summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1y/vla4.C
blob: 74bf66a07d9dcd1fc733859112f377b834d143ff (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
// 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
}