Дано:
#include <iostream>
int main()
{
int a = 42;
auto f = []() {
char a = 'd';
return a;
};
std::cout << "f: " << f() << "\n";
return 0;
}
компилируем...
$ g++ --std=c++11 -Wshadow 1.cpp
1.cpp: In lambda function:
1.cpp:6:10: warning: declaration of ‘a’ shadows a previous local [-Wshadow]
char a = 'd';
^
1.cpp:4:7: note: shadowed declaration is here
int a = 42;
^