<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59558>59558</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Parameter constness taken from declaration rather than definition
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
wthrowe
</td>
</tr>
</table>
<pre>
The indicated line should be rejected because `x` is marked const, but it is not. Interestingly, it *is* rejected if the type in the declaration in the class is changed to `const int`, even if the out-of-line definition is changed to plain `int`.
```c++
template <typename T>
struct X {
int f(X&&, int);
int value;
};
template <typename T>
int X<T>::f(X&& u, const int x) {
x += u.value; // <----
return x;
}
int main() {
X<int>{}.f(X<int>{1}, 0);
return 0;
}
```
godbolt: https://godbolt.org/z/3GzheqTjj
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEk8Fu4zgMhp-GvhA2ZClOnIMPmWSy2NseeuhVtulYHVnKSnSbztMv5CRtWiwwgIDEJPX_HylQx2hOjqiB6gdUh0zPPPrQvPEY_Btlre_fm6eR0LjedJqpR2scYRz9bHtsCQO9UJfiLXV6joSwFhdYCzQRJx1-UY-dd5FB7rGdGQ2njPNcIP7tmAJFNu5k31OBYQS5MxHk7lPYDMgjIb-fE8byv6fO6qDZeHcPdVbHmKS7UbsT9cg-oSzeaBzDWiQHeiV3V_Qz537Il4Z6GowzV8EvGmerjUtKV40CxAHELqktpwP5I50lyjSdrWZCUPuE6_RE-ATq5zUdOcwd4zPC5nYBExkOIOtnkOvl7BdYuQV1q3msfNV2ps_M5vCt6g8ASeIZ1H6JqB2o3YM1zsn8Y154Abl9JL1g6lMdcC7uGIggjyCPyS7P8xzvtYF4Dg4vX1AfOJP-pI0DWX9zSXhpAOpnCm4OxZXwIVgmLblH8TikD0vxP5b3t7p-nnzfesugdjgyn2MaxNLFLVH4cAJ5_A3yqP76PdK_Ty8vWd-ofqu2OqOmXG9KWVZ1rbKxqYVQw7CqxXaj2nXZ1l1bkt5sRD30q6GVmWmkkLKU5bqsVS1UIXpNld4OVVl2fd-VsBI0aWMLa1-n5J2ZGGdqqm1V1ZnVLdm4LKeUjt5wSYKUaVdDk-7k7XyKsBLWRI6fKmzYUvOPDnoipnB9WEcxIutf5HAIfvqyR0HzSAF51O5hG7I52ObbnAyPc1t0fgJ5TH63n_wcfFpZkMeFMoI8Ll38FwAA__8YQFGj">