This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/64892] New: C++1y: generic lambdas, decltype(auto), and rvalue references, oh my!
- From: "eric.niebler at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 01 Feb 2015 01:10:46 +0000
- Subject: [Bug c++/64892] New: C++1y: generic lambdas, decltype(auto), and rvalue references, oh my!
- Auto-submitted: auto-generated
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.