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&)'"

Reply via email to