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++/48457] New: [C++0x] GCC does not recognize function rvalue reference expressions as lvalues


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).


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