Comments
Patch
@@ -6019,6 +6019,10 @@ cxx_eval_call_expression (const constexpr_call *old_call, tree t,
return t;
}
+ /* Shortcut trivial copy constructor/op=. */
+ if (call_expr_nargs (t) == 2 && trivial_fn_p (fun))
+ return convert_from_reference (get_nth_callarg (t, 1));
+
/* If in direct recursive call, optimize definition search. */
if (old_call != NULL && old_call->fundef->decl == fun)
new_call.fundef = old_call->fundef;
new file mode 100644
@@ -0,0 +1,14 @@
+// PR c++/47503
+// { dg-options "-std=c++0x -fno-elide-constructors" }
+
+struct A
+{
+ int i;
+ A ();
+};
+
+struct B
+{
+ A a;
+ B (A &aa) : a (aa) { }
+};
With -fno-elide-constructors, the constexpr code was trying to set the type of a temporary of class type which was not represented by a CONSTRUCTOR. The simplest solution to this is to just skip trivial copies at expand time and return the argument directly. Tested x86_64-pc-linux-gnu, applied to trunk. commit b36ba34cf1f04e86dcb8b30c5cf90bb1900bcfee Author: Jason Merrill <jason@redhat.com> Date: Sat Feb 19 09:41:57 2011 -0500 PR c++/47503 * semantics.c (cxx_eval_call_expression): Shortcut trivial copy.