Message ID | 20220321222446.2596733-1-jason@redhat.com |
---|---|
State | New |
Headers | show |
Series | [pushed] c++: initialized array of vla [PR58646] | expand |
diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc index 7575597c8fd..08767679dd4 100644 --- a/gcc/cp/init.cc +++ b/gcc/cp/init.cc @@ -4395,6 +4395,7 @@ build_vec_init (tree base, tree maxindex, tree init, if (init && TREE_CODE (atype) == ARRAY_TYPE && TREE_CONSTANT (maxindex) + && !vla_type_p (type) && (from_array == 2 ? vec_copy_assign_is_trivial (inner_elt_type, init) : !TYPE_NEEDS_CONSTRUCTING (type)) diff --git a/gcc/testsuite/g++.dg/ext/vla24.C b/gcc/testsuite/g++.dg/ext/vla24.C new file mode 100644 index 00000000000..0a99c003ffb --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/vla24.C @@ -0,0 +1,7 @@ +// PR c++/58646 +// { dg-additional-options -Wno-vla } + +void foo(int n) +{ + int a[2][n] = {}; +}