PR c++/84927
* constexpr.c (cxx_eval_bare_aggregate): Update constructor's flags
as we evaluate the elements.
(cxx_eval_constant_expression): Verify constructor's flags
unconditionally.
* g++.dg/cpp1y/nsdmi-aggr9.C: New test.
From-SVN: r258691
+2018-03-20 Marek Polacek <polacek@redhat.com>
+
+ PR c++/84978, ICE with NRVO.
+ * constexpr.c (cxx_eval_constant_expression): Handle the case when
+ a RESULT_DECL isn't in the hash map.
+
2018-03-20 Jason Merrill <jason@redhat.com>
PR c++/84978, ICE with NRVO.
/* We ask for an rvalue for the RESULT_DECL when indirecting
through an invisible reference, or in named return value
optimization. */
- return (*ctx->values->get (t));
+ if (tree *p = ctx->values->get (t))
+ return *p;
+ else
+ {
+ if (!ctx->quiet)
+ error ("%qE is not a constant expression", t);
+ *non_constant_p = true;
+ }
+ break;
case VAR_DECL:
if (DECL_HAS_VALUE_EXPR_P (t))
+2018-03-20 Marek Polacek <polacek@redhat.com>
+
+ PR c++/84978, ICE with NRVO.
+ * g++.dg/opt/nrv19.C: New test.
+
2018-03-20 Nathan Sidwell <nathan@acm.org>
PR c++/84962
--- /dev/null
+// PR c++/84978
+// { dg-do compile }
+
+struct S {
+ void (*fn)();
+ int a[10];
+};
+
+S
+foo ()
+{
+ S s;
+ s.fn ();
+ return s;
+}