[clang-tidy][false-positive] `performance-unnecessary-value-param` when passing `std::function` rvalue into `std::map::try_emplace`
Open
@rturrado is already working on this.
Since Feb 2, 2026.
clang-tidy
false-positive
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
clang-tidy warns performance-unnecessary-value-param when passing an std::functional rvalue into std::map::try_emplace(). std::map::try_emplace() will (in some cases) move from rvalues passed into it, so I think the warning is bogus. Or at least, the recommended fix shouldn't be a const lvalue reference.
https://godbolt.org/z/bjYqaP857
<source>:6:33: warning: the parameter 'f' of type 'std::function<void ()>' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
6 | void func(std::function<void()> f) {
| ^
| const &
1 warning generated.
Current trunk: 487de1ad7b11c9faad9b890b37e0dec44433fc04
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.