c++: Tweak PR101029 fix
authorJason Merrill <jason@redhat.com>
Wed, 16 Jun 2021 21:42:15 +0000 (17:42 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 17 Jun 2021 03:38:32 +0000 (23:38 -0400)
The case of an initializer with side effects for a zero-length array seems
extremely unlikely, but we should still return the right type in that case.

PR c++/101029

gcc/cp/ChangeLog:

* init.c (build_vec_init): Preserve the type of base.

gcc/cp/init.c

index 622d6e9..4bd942f 100644 (file)
@@ -4226,7 +4226,7 @@ build_vec_init (tree base, tree maxindex, tree init,
     {
       /* Shortcut zero element case to avoid unneeded constructor synthesis.  */
       if (init && TREE_SIDE_EFFECTS (init))
-       base = build2 (COMPOUND_EXPR, void_type_node, init, base);
+       base = build2 (COMPOUND_EXPR, ptype, init, base);
       return base;
     }