diff --git a/gcc/cp/init.cc b/gcc/cp/init.cc
index ae516407c9278bf2d92d574a11478d2119b70b30..7dcc1152c720caa6393d8deae8dd3c6f7d35758b 100644
--- a/gcc/cp/init.cc
+++ b/gcc/cp/init.cc
@@ -5109,6 +5109,15 @@ build_vec_init (tree base, tree maxindex, tree init,
     {
       if (!saw_non_const)
 	{
+	  /* If we're not generating the loop, we don't need to reset the
+	     iterator.  */
+	  if (cleanup_flags
+	      && !vec_safe_is_empty (*cleanup_flags))
+	    {
+	      auto l = (*cleanup_flags)->last ();
+	      gcc_assert (TREE_PURPOSE (l) == iterator);
+	      (*cleanup_flags)->pop ();
+	    }
 	  tree const_init = build_constructor (atype, const_vec);
 	  return build2 (INIT_EXPR, atype, obase, const_init);
 	}
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-array23.C b/gcc/testsuite/g++.dg/cpp0x/initlist-array23.C
new file mode 100644
index 0000000000000000000000000000000000000000..cda2afb9fcccdae3ab5eb5a1940a85583c247943
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-array23.C
@@ -0,0 +1,28 @@
+// PR c++/117985
+// { dg-do compile { target c++11 } }
+
+struct _Vector_impl {
+  constexpr
+    _Vector_impl() {}
+};
+struct _Vector_base {
+  ~_Vector_base();
+  _Vector_impl _M_impl;
+};
+struct vector : private _Vector_base {};
+struct string {
+  string();
+};
+struct VEC {
+  vector pane{};
+};
+struct FOO {
+  VEC screen[1]{};
+  string debug_name;
+};
+
+int
+main ()
+{
+  FOO{};
+}
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-array24.C b/gcc/testsuite/g++.dg/cpp0x/initlist-array24.C
new file mode 100644
index 0000000000000000000000000000000000000000..7dda00d5c0b834ffcf75fec8656aa435753a0ad9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-array24.C
@@ -0,0 +1,27 @@
+// PR c++/117985
+// { dg-do compile { target c++20 } }
+
+struct _Vector_impl {
+  constexpr _Vector_impl() {}
+};
+struct _Vector_base {
+  constexpr ~_Vector_base() {}
+  _Vector_impl _M_impl;
+};
+struct vector : private _Vector_base {};
+struct string {
+  string();
+};
+struct VEC {
+  vector pane{};
+};
+struct FOO {
+  VEC screen[1]{};
+  string debug_name;
+};
+
+int
+main ()
+{
+  FOO{};
+}