Debian Codegraph @

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

raw
1 // PR c++/57408
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-Wno-vla" }
4
5 template<typename Callable>
6 struct Impl
7 {
8 Callable func;
9 Impl(Callable f) : func(f) { }
10 virtual void run() { func(); }
11 };
12
13 template<typename Callable>
14 void call(Callable f)
15 {
16 Impl<Callable>(f).run();
17 }
18
19 extern "C" int printf(const char*, ...);
20
21 int main(){
22 int y = 2;
23 float fa[2][y];
24 fa[0][0]=0.8;
25 fa[0][1]=1.8;
26 auto fx=[&](){
27 for(int c=0; c<2; c++){
28 printf("use me", fa[0][c]); // { dg-prune-output "sorry" }
29 }
30 };
31 call(fx);
32 }