This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH to build_over_call for c++/23372
- From: Jason Merrill <jason at redhat dot com>
- To: "gcc-patches >> GCC Patches" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 23 Aug 2006 00:27:03 -0400
- Subject: C++ PATCH to build_over_call for c++/23372
The problem in 23372 was that when the C++ front end does argument
conversions for pass by value, it forces the lvalue to rvalue
conversion, which means creating a temporary object. This is what we
want for TREE_ADDRESSABLE types which we pass by invisible reference,
but for POD structs it means first the front end copies the argument
into a temporary, then build_call copies the temporary into the
parameter slot.
Fixed by skipping the lvalue->rvalue conversion when we know that
build_call will take care of it for us.
I haven't been able to think of a way to test for this optimization in
the automated testsuite, so I'm not adding a test. Suggestions welcome.
Tested x86_64-pc-linux-gnu, applied to trunk.
2006-08-22 Jason Merrill <jason@redhat.com>
PR c++/23372
* call.c (build_over_call): Don't make a copy here if build_call
will make one too.
Index: cp/call.c
===================================================================
*** cp/call.c (revision 116332)
--- cp/call.c (working copy)
*************** build_over_call (struct z_candidate *can
*** 4847,4852 ****
--- 4847,4858 ----
tree type = TREE_VALUE (parm);
conv = convs[i];
+
+ /* Don't make a copy here if build_call is going to. */
+ if (conv->kind == ck_rvalue
+ && !TREE_ADDRESSABLE (complete_type (type)))
+ conv = conv->u.next;
+
val = convert_like_with_context
(conv, TREE_VALUE (arg), fn, i - is_method);