When I implemented the [over.match.ref] rule that a reference conversion
function needs to match l/rvalue of the target reference type it changed our
handling of this testcase. It seems to me that our current behavior is what
the standard says, but it doesn't seem desirable, and all the other
compilers have our old behavior. So let's limit the change to non-templates
until there's some clarification from the committee.
PR c++/90546
* call.c (build_user_type_conversion_1): Allow a template conversion
returning an rvalue reference to bind directly to an lvalue.
2020-01-28 Jason Merrill <jason@redhat.com>
+ PR c++/90546
+ * call.c (build_user_type_conversion_1): Allow a template conversion
+ returning an rvalue reference to bind directly to an lvalue.
+
PR c++/90731
* decl.c (grokdeclarator): Propagate eh spec from typedef.
EXPR_LOCATION (expr));
}
else if (TYPE_REF_P (totype) && !ics->rvaluedness_matches_p
+ /* Limit this to non-templates for now (PR90546). */
+ && !cand->template_decl
&& TREE_CODE (TREE_TYPE (totype)) != FUNCTION_TYPE)
{
/* If we are called to convert to a reference type, we are trying
--- /dev/null
+// PR c++/90546
+// { dg-do link { target c++11 } }
+
+struct Foo { };
+void test(const Foo&) {}
+Foo f;
+struct Bar {
+ template <class T> operator T&&();
+};
+template<> Bar::operator const Foo&&() {
+ return static_cast<Foo&&>(f);
+}
+int main() {
+ test(Bar{});
+}