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++/64892] New: C++1y: generic lambdas, decltype(auto), and rvalue references, oh my!


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64892

            Bug ID: 64892
           Summary: C++1y: generic lambdas, decltype(auto), and rvalue
                    references, oh my!
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: eric.niebler at gmail dot com

In the following code, gcc seems to be getting the value category wrong for the
return type of the generic lambda:

#include <utility>

int main()
{
    using std::pair;
    using std::declval;
    using X = decltype(declval<pair<int&&,int&&>>().first);
    auto f = [](auto && p) -> decltype(auto) //((decltype(p)&&)p).first)
    {
        return ((decltype(p)&&)p).first;
    };
    using Y = decltype(f(declval<pair<int&&,int&&>>()));
}

In this code, Y becomes an alias for int&. I believe it should be int&&. X is
an alias for int&&, and I think it's doing the same thing. Also, if I replace
the decltype(auto) with decltype(((decltype(p)&&)p).first) -- which is
*exactly* the return expression -- Y becomes an alias for int&&. Seems fishy to
me.


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