commit df1f90245e5436ceadf6b3df5cc6f7ef7e0536c0
Author: Jason Merrill <jason@redhat.com>
Date: Fri Jun 17 16:45:44 2011 -0400
PR c++/49458
* call.c (convert_class_to_reference_1): Allow binding function
lvalue to rvalue reference.
@@ -1362,6 +1362,8 @@ convert_class_to_reference_1 (tree reference_type, tree s, tree expr, int flags)
/* Don't allow binding of lvalues to rvalue references. */
if (TYPE_REF_IS_RVALUE (reference_type)
+ /* Function lvalues are OK, though. */
+ && TREE_CODE (TREE_TYPE (reference_type)) != FUNCTION_TYPE
&& !TYPE_REF_IS_RVALUE (TREE_TYPE (TREE_TYPE (cand->fn))))
cand->second_conv->bad_p = true;
}
new file mode 100644
@@ -0,0 +1,10 @@
+// PR c++/49458
+// { dg-options -std=c++0x }
+
+typedef void ftype();
+
+struct A {
+ operator ftype&(void);
+};
+
+ftype &&frvref = A();