<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/86447>86447</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`performance-move-const-arg` not reported with `emplace_back()` and such
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
firewave
</td>
</tr>
</table>
<pre>
```cpp
#include <string>
#include <vector>
class C
{
public:
C(int i, const std::string& s);
};
int main()
{
std::vector<C> v;
{
std::string s = "str";
C c(0, std::move(s));
}
{
std::string s = "str";
v.push_back(C(0, std::move(s)));
}
{
std::string s = "str";
v.emplace_back(0, std::move(s)); // no warning
}
}
```
```
<source>:17:16: warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg]
17 | C c(0, std::move(s));
| ^~~~~~~~~~ ~
<source>:24:26: warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg]
24 | v.push_back(C(0, std::move(s)));
| ^~~~~~~~~~ ~
```
https://godbolt.org/z/vqM1orqdP
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMVcGu6yYQ_ZrxZpTIHrATL7zIdW52lfoHFcYkoSXgB9jR6-J9e4Vfcn2Td9srvXZRFBFshjNnzhxkEYI-WaUaKF-g3GdijGfnm6P26iomlXWu_9pAlX__yWGAfA_5DohpK83YKwTWhui1PQF7_WhzUjI6v2zOszQiBGxvrzYv3xfD2Bktgd2CEBFboK22ETVQi9LZEDHEPoWw3S0tVRiAamAvd7j9sp7nBHAR2gJtU-Bj0pTlDfJOtm2BveL0hJNCl3NPPDAgsD0CUYgeiN7O4m08PrUogbZ5KusN6OImBbSdq3lXEKaKFgJ_S-g2fpLXtB7GcP6tE_IPoG37Gbn3_GYWP1D8L9Wa1uoyGCHVnd8nwiHQAeiA1uFVeJts8iTlsrib-72wzy9ZG9zopUo2Zrtik6YK2O4Nne1wSHfJntCrMJqI7vgDP6AaRUBxM7JXR-WVlQqFP40XZWNibh2mcLxqY1DIOApjvuJZDIOyCOXLoPzR-YuwUq1S4GoGWwl_gnLpQbFB2LT4c25bzt2bUb5-uw_89qEmxNP0v9aE-ENt_87w-JFOnyj2aKpzjENIqWarnlzfORPXzp-ADn8CHaYvvxTOf-l_zfqG9TWrRaaaYlMULOd1ybNzw5Toyw0dRUcVlTnv-fFI3UaWveCyqPpMN5QTzxnxYkt1wdeypo5VNVdVLTiVR-C5ught1sZMl5Q70yGMqtlWnG8yIzplwvxpILLqivNmuq3lPvNNOrPqxlMAnhsdYlhQoo5Gpe_GP3SmytG61PHB-ah6vOp4Rqjyp5uehK9yFLbHMMpzNnrTPEmn43ns1tJdgA6Jwu1vNXj3u5IR6DATD0CHubC_AgAA__8Xre4u">