This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/50835] [4.7 Regression] Lvalue-ness of conditional operator results is incorrect in a function template
- 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: Sun, 23 Oct 2011 12:23:41 +0000
- Subject: [Bug c++/50835] [4.7 Regression] Lvalue-ness of conditional operator results is incorrect in a function template
- Auto-submitted: auto-generated
- References: <bug-50835-4@http.gcc.gnu.org/bugzilla/>
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&)'"