Issue |
68105
|
Summary |
[clang-tidy] False positive for cppcoreguidelines-missing-std-forward when forwarding into lambda
|
Labels |
clang-tidy
|
Assignees |
|
Reporter |
nilssonk
|
The following seemingly valid code
```
#include <iostream>
#include <utility>
template<typename F>
auto make_lambda(F&& f)
{
return [f = std::forward<F>(f)] { f(); };
}
int main()
{
auto g = make_lambda([] { std::cout << "hello\n"; });
g();
}
```
results in the error
```
repro.cpp:5:22: error: forwarding reference parameter 'f' is never forwarded inside the function body [cppcoreguidelines-missing-std-forward,-warnings-as-errors]
5 | auto make_lambda(F&& f)
```
Encountered on
```
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.3 LTS
Release: 22.04
Codename: jammy
```
```
$ clang-tidy --version
Ubuntu LLVM version 17.0.2
Optimized build.
```
installed with the script from https://apt.llvm.org/llvm.sh .
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs