<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58499>58499</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-tidy check bugprone-use-after-move does not detect validation of shared_ptr after move
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
PiotrNycz
</td>
</tr>
</table>
<pre>
Consider this code https://godbolt.org/z/jraWq3sfM
```
#include <memory>
#include <iostream>
struct Foo {
Foo(std::shared_ptr<int> a)
: a(std::move(a))
{
if (a == nullptr) // should be: if (this->a == nullptr)
std::cerr << "Error!\n";
// std::cout << *a; -- here reported use-after-move -- but not in line 8!
}
std::shared_ptr<int> a;
};
int main() {
Foo foo(std::make_shared<int>(2));
return *foo.a;
}
```
I'd expect that bugprone-use-after-move tells me I am using parameter `a` (not member `a`) after std::move in `if (a == nullptr)` -- but it does not.
Maybe it is ok -- maybe this check is designed only for checking access to underlying values -- not to just use moved object in any way. Then maybe some other check would be nice to have -- like misleading-use-of-parameter -- when member and parameters in member function share the same name?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyFVFGPmzAM_jXwYrWi0NLywEPvbiftYdMeJu1xCsSU3IWkS8Ld2K-fDbRcTzcNhYBj-7Pz2Ull5VDeW-OVRAehVR5qKxHaEM4-yo5R-kjjZGVldVhbdyLpD71PTvz4lfnmS5Q8RMlxnvNkHpOYZsrUuie4KLvvsLNuiLJPHymV9cGh6Bb1ONNiXwd4tBai_d20BixG6cEHyfllR98Kh_LnOTgGMoEwQERpARd7oAhHXlp8OvuCJLPZO8slzPSoBtiQIB5ogOm15kjsNFIDvrW9llAhB5msmcYVpfGB1y04P9ecanSOuaBBIOkn5yx5bKLdvSExyu4Abr0vCVwBbB8WgKNgl9UKWnQIDs_WBZTQe1yJJqBbMQesr8jL2ADKgFYG4cBB3xDycBH-w3g2M8ce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