http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50835
Bug #: 50835
Summary: [4.7 Regression] Lvalue-ness of conditional operator
results is incorrect in a function template
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
Created attachment 25578
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25578
Test case (which incorrectly fails to be compiled on gcc-4.7)
Suppose we have the following class
template<typename T>
struct rvalue_probe
{
explicit rvalue_probe(T &t) : value(t) {}
operator T () { return value; }
operator T&() const { return value; }
T& value;
};
Then,
// std::vector<int> v;
true ? rvalue_probe<std::vector<int> >(v) : v
should be evaluated to an lvalue.
But in a function template, this is incorrectly evaluated to an rvalue.
Tested on gcc-4.7.0 20111022 (in a C++03 mode).