[Bug c++/93842] generic lambda accesses a variable with with automatic storage duration that wasn't captured by the lambda expression
marxin at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Feb 20 08:26:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93842
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed that clang really rejects the code:
$ clang pr93842.cc -Wunused -std=c++14 -c
pr93842.cc:4:20: error: variable 'ch' cannot be implicitly captured in a lambda
with no capture-default specified
[](auto) { return ch; }; // NOT OK
^
pr93842.cc:2:17: note: 'ch' declared here
constexpr char ch = '=';
^
pr93842.cc:4:2: note: lambda expression begins here
[](auto) { return ch; }; // NOT OK
^
pr93842.cc:4:2: warning: expression result unused [-Wunused-value]
[](auto) { return ch; }; // NOT OK
^~~~~~~~~~~~~~~~~~~~~~~
1 warning and 1 error generated.
For the record, we print the warning since r8-3497-g281e6c1d8f1b4ca5.
More information about the Gcc-bugs
mailing list