This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/48457] New: [C++0x] GCC does not recognize function rvalue reference expressions as lvalues
- From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 5 Apr 2011 09:44:25 +0000
- Subject: [Bug c++/48457] New: [C++0x] GCC does not recognize function rvalue reference expressions as lvalues
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48457
Summary: [C++0x] GCC does not recognize function rvalue
reference expressions as lvalues
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: daniel.kruegler@googlemail.com
CC: jason@redhat.com
GCC 4.7.0 rejects the following code in C++0x mode:
template<class T>
T&& create();
template<class T, class Arg>
void test() {
T t(create<Arg>());
(void) t;
}
int main() {
test<void(&)(), void()>();
}
"error: invalid initialization of non-const reference of type 'void
(&)()' from an rvalue of type 'void()'"
This code should be well-formed, because the expression create<void()>(), which
is a function call expression returning an rvalue reference of function type,
is supposed to be an lvalue, not an xvalue. According to (N3242) 3.10
[basic.lval] and confirmed by 5 [expr] p. 6 there are only xvalues of object
type and the semantics of above initialization is described by 8.5.3
[dcl.init.ref] p. 5 bullet 1, sub-bullet 1 where an lvalue-reference binds to
an lvalue (of function type).