Comments

In templates, we do overload resolution and then throw away most of it,
going back to the pre-conversion arguments. But when the call returns a
reference, we shouldn't elide the dereference and pretend it returns by
value, as that confuses lvalue_p.
Tested x86_64-pc-linux-gnu, applying to trunk.
commit 79330512f8ade4ecff47ab8cb8c050440d9648e0
Author: Jason Merrill <jason@redhat.com>
Date: Tue Mar 8 08:46:41 2011 -0500
PR c++/47999
* semantics.c (finish_call_expr): Preserve reference semantics
in templates.