[Bug c++/79328] Wshadow and lambda captures
arnaud02 at users dot sourceforge.net
gcc-bugzilla@gcc.gnu.org
Fri Sep 27 15:13:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79328
Arnaud Desitter <arnaud02 at users dot sourceforge.net> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |arnaud02 at users dot sourceforge.
| |net
--- Comment #3 from Arnaud Desitter <arnaud02 at users dot sourceforge.net> ---
This defect makes -Wshadow=local difficult to use with immediately invoked
lambda expressions. For instance,
gcc 9.2 compiles:
#include <array>
auto f(int s) {
const auto v = []{
std::array<int,2> v = {1, 2};
return v;
}();
return v.size();
}
with:
source>: In lambda function:
<source>:4:25: warning: declaration of 'v' shadows a previous local [-Wshadow]
4 | std::array<int,2> v = {1, 2};
| ^
<source>:3:14: note: shadowed declaration is here
3 | const auto v = []{
| ^
More information about the Gcc-bugs
mailing list