[Bug c++/57575] lvalue function accepted as an rvalue

daniel.kruegler at googlemail dot com gcc-bugzilla@gcc.gnu.org
Mon Jun 10 12:06:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57575

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
Your assumptions are mistaken. In C++ it is valid to bind a function value to
an rvalue reference of that function type. It is only so, that binding to an
lvalue reference is preferred.

In other words, the following is valid as well:

float f() { return 0.f; }
float (&&r)(void) = f;

See for example [over.ics.ref] p3 (emphasis mine):

"Except for an implicit object parameter, for which see 13.3.1, a standard
conversion sequence cannot be formed if it requires [..] binding an rvalue
reference to an lvalue **other than a function lvalue**."


More information about the Gcc-bugs mailing list