<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/66204>66204</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
false positive for clang-tidy rule 'misc-const-correctness'
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy,
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
a3emdot
</td>
</tr>
</table>
<pre>
I use clang-tidy 15.0.7 from Fedora 37
consider the following reproducer
```
#include <iostream>
class X {
public:
int a;
int b;
};
void func( X& x, int X::* m )
{
/*const*/ X& tmp = x;
tmp.*m = 77;
}
int main()
{
X x;
x.a = 0;
x.b = 0;
std::cout << x.a << " " << x.b << std::endl;
func(x, &X::a);
std::cout << x.a << " " << x.b << std::endl;
return 0;
}
```
The ```/* const */``` marked line gets tagged with 'misc-const-correctness'.
Though adding that 'const' clearly results in a compilation error with g++ (12.3.1) or clang++ (15.0.7)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VM2u8jgMfRp3Y1EFB1q66AIugzT7Wdxtmpg2M2mDkvT-vP2oLb_fHc3ykyAEH-ec2I6tYrTtwFzD9gDbY6bG1PlQK8m98SlrvPmu_8QxMmqnhnaVrPnG9TYXeYnn4Hs8sfFBoSxBHEHsl1X7IVrDAVPHePbO-U87tBj4ErwZNYercyGun-UvSTtoNxpGkG_WxxRY9SD_eKF2KkZ8RygPi-EyNs5qkPubV2WHhArk4cXQPAzl8Qmc1g9vDZ7HQQPt8B2owC-gN5yOvU_Ecg-0xx6BqhvFgxzoBDRHnID2QKeFIfUXBHnEr1-0QFSpv-RA-37Gy_LlYk-ek3yv7AC0-0_h9xfu6itXM6F4NTY_jFcoJrPEpv2YpoSDfMOFZN4C0fK9Ic1tez_Jg3E_ia-JnFMIVFwzqKYYft8lAqcxDM9x35P7y6Ob1786xgcwVxTnkuJS0zuGvQr_sEFnB8aWU8Sk2pYNftrUIVDZ26hX89GV9iGwTgPHCFTmNyU_th0qY6aOSJ2aJMrr8ylRO1bBfWPgOLoU0Q6oUPv-Yp1K1g_IIfiwqLVAB6ADAu3WlMt8DVShD0unPmFzt96fUGZqaSpZqYzrdVFtClGW2yLralmcBW3Xlaz0juW51FW50ZJ3vDlLEoXJbE2CpKjWck1Esshl1Wy2TKKUoip0sYaN4F5Zlzv30ec-tJmNceS6KEhsMqcadnEeNESPaQJEQG9ANPAnzv6TZXvMQj3RrJqxjbARzsYUH8TJJsf1WbnIePHRJvsxTZrwPKbC6Ph_S5KNwdVdSpc4t_gJ6NTa1I1Nrn0PdJrUrj-rS_B_s05Ap_mOEeg0h_VvAAAA__9y1HOD">