This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/66672] std::is_same wrong result for captured reference value inside a lambda
- From: "hacoo36 at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 24 Aug 2017 23:09:08 +0000
- Subject: [Bug c++/66672] std::is_same wrong result for captured reference value inside a lambda
- Auto-submitted: auto-generated
- References: <bug-66672-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66672
Henry Cooney <hacoo36 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hacoo36 at gmail dot com
--- Comment #1 from Henry Cooney <hacoo36 at gmail dot com> ---
I tested this behavior as of g++ 7.2.0; is_same<decltype((j)), ...> still seems
to indicate that j is an int& inside the lambda.
I think this behavior is probably incorrect WRT the language spec. For example,
the following code produces a compile-time error ('assignment of read-only
variable 'j''):
====
int main() {
int i = 100;
int &j = i;
cout << j;
[=]()
{
cout << is_same<decltype((j)), int &>::value
<< is_same<decltype((j)), int const&>::value;
cout << endl;
j = j + 1;
}();
cout << j;
}
====
That suggests that the correct type of j is indeed int const&, not int&!