view gcc/testsuite/g++.dg/cpp1y/vla2.C @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 84e7813d76e9
children
line wrap: on
line source

// N3639 allows initialization and capture of VLAs
// { dg-do run { target c++11 } }
// { dg-options "-Wno-vla" }
// { dg-require-effective-target alloca }

void f(int n)
{
  int ar[n] = { 42 };
  auto l = [&] { return ar[0]; };
  if (l() != 42) __builtin_abort ();
}

int main()
{
  f(1);
}