@@ -2955,8 +2955,8 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
if (lval)
return t;
/* We ask for an rvalue for the RESULT_DECL when indirecting
- through an invisible reference. */
- gcc_assert (DECL_BY_REFERENCE (t));
+ through an invisible reference, or in named return value
+ optimization. */
return (*ctx->values->get (t));
case VAR_DECL:
new file mode 100644
@@ -0,0 +1,20 @@
+// { dg-do compile }
+// { dg-options "-std=c++1y" }
+
+struct arr {
+ constexpr arr() : elem() { }
+ char elem[17];
+};
+
+constexpr
+arr f()
+{
+ arr result;
+ return result;
+}
+
+constexpr arr a { f() };
+
+int main()
+{
+}