<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58093>58093</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`misc-const-correctness` not reported for pointer
</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>
The following reports nothing by default:
```cpp
#include <list>
class A
{
public:
void f() const;
};
extern void f(std::list<A> l)
{
std::list<A>::iterator it;
for(it = l.begin(); it != l.end(); ++it)
{
A* a = &(*it); // no warning
a->f();
}
}
```
This is also not reported if you completely remove the `f()` method.
If you enable `misc-const-correctness.WarnPointersAsValues` you get the warning on the pointer though:
```
<source>:14:9: warning: variable 'a' of type 'A *' can be declared 'const' [misc-const-correctness]
A* a = &(*it); // no warning
^
```
https://godbolt.org/z/KEbE6acvW
CC @JonasToth
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVEuT2yAM_jX2hdmM41figw_OY2faXnrY6Z4ByzYdAh7ASdNfX4GTTbKT9lQPxhJCn4Q-Yabbc_02AOm0lPokVE8MjNo4S5R2g9fZmbTQ0Um6KGuiZBcl17lM5sHH8bKSZkJxObVAomwrhUWX_b0Ll9RacvVfbWaB4DNOTAr-EYFcnqMWLemidB2lFeFaecTN1X13k8MMvxwYdfOxrvWAWTNnskVxTyQiPYn_bO-8IBCUOm2IuMX2Hp02GEM4POqOyAWDXqg5UdxG_Hq6nE2g2pshSjc4EOuahsd6SMU_WMqG0AAdpWXwbmafAPGKAwkiJ2oUcvToS18w9-4j4n2U3a10jxTel_FtEJbgoNJq3wWXjoCWiI6c9YQ8HEYJDuQZTQd9BOKwgxDlGrRMyAHcoNvFPe6X2RsUZTJsPwjLXwKpOBsD3CmwdvGOh_quhcK628b-oHIC6yG9cw8uBLscnGgV1HHejrKe-uHWp5-Ol22tngyHmdtljhNWqPkoI4pHasScX7qi-BLdEXceg97g1Pg1ThVhgNcC-9lgXXBt7k20RcXm-bmiYvf_OI6K_T8YHJwbra9CAOl1y7R0C2161H7j-23P9iXlx_d7p-2WRHnyVStq3_DqkxjqZVnmZVJV6zJu66ytsorGTjgJ9V_Z80Q99Axekys98WRk_Sk34YaJLbCjUJHyeP28jEb_REhUhbW-AdLXYp1UWTzUjLOWr3LO8i4rkq7ka2CoQtWWxSors1hSBtLWyESUpgpOJECgjBTEok6TNF0myTJZZVVeLjIoijVjS57wtKBljkWAAxVy4fPwRYtNHVJiU2_R6H8Q9mbEH5roFUAIh_h0wiY0dScMnOgR4hC7Drn_AcmjjaU">