From ff4deb4b1d0c5947669ddc76fde4db83e28009d8 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 16 Jun 2021 17:42:15 -0400 Subject: [PATCH] c++: Tweak PR101029 fix 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 622d6e9d0c54..4bd942f3f74e 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -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; } -- 2.47.2