This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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**."

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]