<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/154908>154908</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
bugprone-move-forwarding-reference: false positive for move only types
</td>
</tr>
<tr>
<th>Labels</th>
<td>
false-positive
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Dushistov
</td>
</tr>
</table>
<pre>
For such code:
```c++
#include <memory>
void bar(std::unique_ptr<int> t) {}
template <typename T> void foo(T &&t) { bar(std::move(t)); }
int main() {
std::unique_ptr<int> s = std::make_unique<int>(17);
foo(s);
}
```
bugprone-move-forwarding-reference suggets to use `std::forward`:
```
clang-tidy test.cpp \
-checks='bugprone-move-forwarding-reference' \
-header-filter='.*' \
-- -std=c++17
1 warning generated.
/tmp/test.cpp:5:45: warning: forwarding reference passed to std::move(), which may unexpectedly cause lvalues to be moved; use std::forward() instead [bugprone-move-forwarding-reference]
5 | template <typename T> void foo(T &&t) { bar(std::move(t)); }
| ^~~~~~~~~
| std::forward<T>
```
but because of `std::unqiue_ptr` is move only type and `bar` take it by value, usage of this suggestion just cause compilation error:
```
test.cpp:5:45: error: no matching function for call to 'forward'
5 | template <typename T> void foo(T &&t) { bar(std::forward(t)); }
| ^~~~~~~~~~~~
```
so it would be nice, if bugprone-move-forwarding-reference check verifing is type if move only and if it is accepted by value.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy0VU1zozgQ_TXtSxcuWRiDDxwcO_4FuU8J0YAmQmIk4awv-e1bAhNPxrO7OexQKuwS_fH03msQ3qvWEJWQPUF2WokxdNaVp9F3ygd7WVW2vpZn69CPskNpa4L0AGxaOzYvCfwpLnZA4KkyUo81IaTHnnrrrpA-zwmIF6tqrIQDXvhQx0rpYTTqx0jfhuAgPSoTIH3GAHyPkD9BflpSA_WDFmGqG64DGdETvsTgqWhjLfDiBYHvgO-W_F979fZCwIv4OK70Ce8dlAn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