| Issue |
71033
|
| Summary |
clang 17.0.2: No shadowing warning on lambda capture
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
pkl97
|
This simple code does not trigger a -Wshadow warning in clang++ 17.0.2, however g++ 8.5 emits a warning:
```c++
void f()
{
int* ptr=nullptr;
const auto& lambda=[&]()
{
int* ptr=nullptr;
};
}
```
When explicitly capturing "&ptr", a warning is emitted by clang.
If using -Wshadow-all, clang emits a -Wshadow-uncaptured-local warning, although ptr is clearly captured.
```console
lambda_capture.cpp:6:14: warning: declaration shadows a local variable [-Wshadow-uncaptured-local]
int* ptr=nullptr;
^
lambda_capture.cpp:3:10: note: previous declaration is here
int* ptr=nullptr;
^
1 warning generated.
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs