diff mbox series

[pushed] c++: Tweak PR101029 fix

Message ID 20210617033820.2260636-1-jason@redhat.com
State New
Headers show
Series [pushed] c++: Tweak PR101029 fix | expand

Commit Message

Jason Merrill June 17, 2021, 3:38 a.m. UTC
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.

Tested x86_64-pc-linux-gnu, applying to trunk.

	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(-)


base-commit: 6816a44dfe1b5fa9414490a18a4aa723b6f38f18
diff mbox series

Patch

diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 622d6e9d0c5..4bd942f3f74 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;
     }