When we overwrite one CONSTRUCTOR with another, we need to transfer CONSTRUCTOR_NO_IMPLICIT_ZERO as well.

Tested x86_64-pc-linux-gnu, applying to trunk.
commit aa2f91a9e517f9351ae9624d35b27f6a25fc1b97
Author: Jason Merrill <ja...@redhat.com>
Date:   Thu Apr 14 13:08:20 2016 -0400

    	PR c++/70648
    	* constexpr.c (cxx_eval_store_expression): Also copy
    	CONSTRUCTOR_NO_IMPLICIT_ZERO.

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 37cc336..4abff20 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -3149,6 +3149,8 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t,
       CONSTRUCTOR_ELTS (*valp) = CONSTRUCTOR_ELTS (init);
       TREE_CONSTANT (*valp) = TREE_CONSTANT (init);
       TREE_SIDE_EFFECTS (*valp) = TREE_SIDE_EFFECTS (init);
+      CONSTRUCTOR_NO_IMPLICIT_ZERO (*valp)
+	= CONSTRUCTOR_NO_IMPLICIT_ZERO (init);
     }
   else
     *valp = init;
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist10.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist10.C
new file mode 100644
index 0000000..c12347d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist10.C
@@ -0,0 +1,11 @@
+// PR c++/70648
+// { dg-do compile { target c++11 } }
+
+struct C
+{
+  template <class... U>
+  constexpr C (...) : c { static_cast<U &&>(0)... } {}
+  int c[1];
+};
+
+static constexpr int b = C{}.c[0];

Reply via email to