<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56195>56195</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang-tidy 'use-after-move' not detected in constructors
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
blitz-research
</td>
</tr>
</table>
<pre>
Hi,
Clang-tidy is not correctly finding the 'use after move' error in the constructor here (and in all ctors AFAICT), although it is in the main code. This is with 'bugprone-use-after-move' enabled.
```
class Test {
std::string m_path;
size_t m_size;
explicit Test(std::string path)
: m_path(std::move(path)), m_size(path.size()) { // Misses use-after-move of 'path' here...
auto tmp = m_path + "!";
test(std::move(tmp));
std::cout << tmp.size(); // Correctly flags this though
}
void test(std::string str) {
std::cout << str;
}
};
```
I'm using the clang-tidy that's built-in to the last (2022.2) CLion and I'm not sure what version it is.
Bye!
Mark
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyFVE2PozAM_TVwiUB8lLIcOHRajXakndvcR4EYyG5KqiR0tvPr1w60pb2sFEFiG_v5xY9Gi0v9UwbZPkgOQbKbn3vFxz5yUlyYtGzUjrXaGGidurBOjkKOPXMDsCArJwuMdw4MO-ozoIGBMdowOfqIVo_Wmal1aBrA0Cc_-CjIzZViZLds97p7238EWYUw0OwGPfUDk46KL3mOHDetFhCzj4HMln1JNxCCZupPRo8QIZTIQ4luUEbeKBDxurdgmyzLH1vFrWUfYB0LypdrYGWdCPIdLkRP3R4_T9wNQb6KkN_w6dBBm5VjccPfk5It9kCpsennhD4ddnyNp5XvrnVW8XMvP67xM0lL1dkcL_vZTW0gLa-42Lu0Fix7JIbpjmibE5b-VuI4XgPhk9PMHU8syA8LIvyCsmZBltJzxQMu99TiAhkzLIgfw29xrZ6Q9XyPi8qt-8hvPezvk6d4b3EaJD1oRO5Jy8MT_WctBXvGtVCPr4Wn_6Ki0DX4Wx3c3OyPA_WGpB6R8qtG2ruW3MART2lZM0nlIhpt7WNwBh0pI0uyLM4I3P6X1CgRVMqcjzRoJ9TPF-ZgZzCW_F4iD9P9cgG6Ir9_5-ZPKOpcVHnFQyedgnql7Fm8T4qhOgIcEg5epCv92nAyqh6cO1kiyt9OjxqcmrjVRzwodb6-IlTkb0yCRxzBCSxuim1aFeFQ50XRQJYmRVUkRbrlULWbTBSdqLqmLPM2VLwBZeugeMFRG-GL-RQ0dsUhlDWRlGyzTZJtqqSI0040CX7BeVemabIJNgng30LFhCPWpg9N7SHhf8KiU0nr7N2J6pf9CODLYX6c_UGbulHSfUcGLHDTDqFHUPsO_gGAZ5C4">