+2017-06-19 Jason Merrill <jason@redhat.com>
+
+ PR c++/80829 - ICE with constexpr copy of base subobject.
+ * constexpr.c (clear_no_implicit_zero): New.
+ (cxx_eval_call_expression): Call it.
+
2017-06-19 Nathan Sidwell <nathan@acm.org>
PR c++/81124
return t;
}
+/* Clean CONSTRUCTOR_NO_IMPLICIT_ZERO from CTOR and its sub-aggregates. */
+
+static void
+clear_no_implicit_zero (tree ctor)
+{
+ if (CONSTRUCTOR_NO_IMPLICIT_ZERO (ctor))
+ {
+ CONSTRUCTOR_NO_IMPLICIT_ZERO (ctor) = false;
+ tree elt; unsigned HOST_WIDE_INT idx;
+ FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (ctor), idx, elt)
+ if (TREE_CODE (elt) == CONSTRUCTOR)
+ clear_no_implicit_zero (elt);
+ }
+}
+
/* Subroutine of cxx_eval_constant_expression.
Evaluate the call expression tree T in the context of OLD_CALL expression
evaluation. */
/* The result of a constexpr function must be completely initialized. */
if (TREE_CODE (result) == CONSTRUCTOR)
- CONSTRUCTOR_NO_IMPLICIT_ZERO (result) = false;
+ clear_no_implicit_zero (result);
pop_cx_call_context ();
return unshare_constructor (result);
--- /dev/null
+// PR c++/80829
+// { dg-do compile { target c++11 } }
+
+struct A {
+ constexpr A(int a) : _a(a) {}
+ int _a;
+};
+
+struct B : public A {
+ constexpr B(int a) : A(a) {}
+};
+
+int main() {
+ constexpr A a = B(10);
+}