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++/50835] [4.7 Regression] Lvalue-ness of conditional operator results is incorrect in a function template


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

--- Comment #3 from Daniel KrÃgler <daniel.kruegler at googlemail dot com> 2011-10-23 12:23:41 UTC ---
Removing as much templates as possible:

//---
struct A {};

struct B
{
    explicit B(A &t) : value(t) {}
    operator A&() const { return value; }
    A& value;
};

void should_be_lvalue(A&)
{
}

template <typename>
void f()
{
    A v;
    should_be_lvalue(true ? B(v) : v);
}
//---

This code is still rejected in either C++03 or C++11 mode:

"error: invalid initialization of non-const reference of type 'A&' from an
rvalue of type 'A'"
"error: in passing argument 1 of 'void should_be_lvalue(A&)'"


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