A few months back I queued this patch to bring back for GCC 8. Unfortunately I don't remember the context that it came up in, but it affects for instance cases of self-assignment, which can't have a constant value if there is no previous initialization.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 8c5592e0e31ec60bb6b075fca14face587e3084b Author: Jason Merrill <ja...@redhat.com> Date: Tue Apr 11 16:29:37 2017 -0400 * constexpr.c (reduced_constant_expression_p): If CONSTRUCTOR_NO_IMPLICIT_ZERO, check that all fields are initialized. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index a5692fb..2d2f3b8 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -1732,15 +1732,30 @@ reduced_constant_expression_p (tree t) case CONSTRUCTOR: /* And we need to handle PTRMEM_CST wrapped in a CONSTRUCTOR. */ - tree elt; unsigned HOST_WIDE_INT idx; - FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (t), idx, elt) + tree idx, val, field; unsigned HOST_WIDE_INT i; + if (CONSTRUCTOR_NO_IMPLICIT_ZERO (t)) + field = next_initializable_field (TYPE_FIELDS (TREE_TYPE (t))); + else + field = NULL_TREE; + FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t), i, idx, val) { - if (!elt) + if (!val) /* We're in the middle of initializing this element. */ return false; - if (!reduced_constant_expression_p (elt)) + if (!reduced_constant_expression_p (val)) return false; + if (field) + { + if (idx != field) + return false; + field = next_initializable_field (DECL_CHAIN (field)); + } } + if (field) + return false; + else if (CONSTRUCTOR_NO_IMPLICIT_ZERO (t)) + /* All the fields are initialized. */ + CONSTRUCTOR_NO_IMPLICIT_ZERO (t) = false; return true; default: