Debian Codegraph @

gcc/testsuite/g++.dg/cpp1y/vla4.C

raw
1 // Test for range-based for with VLAs.
2 // { dg-do run { target c++11 } }
3 // { dg-options "-Wno-vla" }
4
5 #include <new>
6
7 void f(int i)
8 {
9 int ar[i];
10 int j = 0;
11 for (int& x : ar)
12 x = ++j;
13 [&ar]{
14 int k = 0;
15 for (int x : ar)
16 if (x != ++k)
17 __builtin_abort();
18 }();
19 }
20
21 int main()
22 {
23 f(42); // OK
24 }