diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc
index 7575597c8fd1075fc90c8c62e0b8e965ab535a4f..08767679dd4410e0d84cfa27f83d4ba9bc4d8a63 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 0000000000000000000000000000000000000000..0a99c003ffb26b921ecb26eccc295d4a943f8d55
--- /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] = {};
+}