This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/64834] New: Captured variable not available in unevaluated context in a lambda with auto argument
- From: "holger dot grund at ix-n dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 28 Jan 2015 13:11:11 +0000
- Subject: [Bug c++/64834] New: Captured variable not available in unevaluated context in a lambda with auto argument
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64834
Bug ID: 64834
Summary: Captured variable not available in unevaluated context
in a lambda with auto argument
Product: gcc
Version: 4.9.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: holger.grund@ix-n.net
Created attachment 34605
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34605&action=edit
Repro
$ cat t.cpp
template <typename F>
void e(F f)
{
f(1);
}
template <int I>
void bar() {
int x;
e([&] (const int& y) { (void)sizeof(x); }); // ok
e([&] (const auto& y) { (void)sizeof(x); }); // error
}
void baz() { bar<1>(); }
$ c++ t.cpp -std=c++1y -c
t.cpp: In instantiation of âbar()::<lambda(const auto:1&)> [with auto:1 = int;
int I = 1]â:
t.cpp:4:6: required from âvoid e(F) [with F = bar() [with int I =
1]::<lambda(const auto:1&)>]â
t.cpp:11:47: required from âvoid bar() [with int I = 1]â
t.cpp:15:21: required from here
t.cpp:11:41: error: âxâ was not declared in this scope
e([&] (const auto& y) { (void)sizeof(x); }); // error
^
I don't see why x wouldn't be available in the second lambda.
File with