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] New: [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

             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: unassigned@gcc.gnu.org
        ReportedBy: mimomorin@gmail.com


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


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