<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/141381>141381</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
False-positive `readability-convert-member-functions-to-static` when using explicit object parameters
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
chriselrod
</td>
</tr>
</table>
<pre>
```c++
#include <print>
#include <string>
struct Hello {
std::string str_;
void hello(this Hello &self) { std::println("Hello, {0}!", self.str_); }
};
int main() {
Hello hi{"world"};
hi.hello();
return 0;
}
```
Saving this file as `explicit_object_param.cpp`, I get
```
$ clang-tidy --checks=readability-convert-member-functions-to-static explicit_object_param.cpp -- --std=c++23
1 warning generated.
/home/chriselrod/Documents/progwork/cxx/misc/explicit_object_param.cpp:7:8: warning: method 'hello' can be made static [readability-convert-member-functions-to-static]
7 | void hello(this Hello &self) { std::println("Hello, {0}!", self.str_); }
| ^
| static
```
Of course, `static` is illegal there
```
explicit_object_param.cpp:7:21: error: an explicit object parameter cannot appear in a static function
7 | static void hello(this Hello &self) { std::println("Hello, {0}!", self.str_); }
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
1 error generated.
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VE2PozgQ_TWVS4nImI-EAwe6M2j2tIf9AS1jKuAdYyPbpLsv-9tXhjCtTau1mssglIDtV6_e88PCezUYohqKJyguB7GE0bpajk550s72h8727zWUbLsl8Kd4swZ4pozUS08I2fPslAmQffs04YNTZrjPsMYHt8iA30lri3CKhRB96CFrIGu2xeiDe4HsaUMg3qzqcYwI4OcwKr_DeelJX4FXsdJHlbUXbYCfgfPvG-45LmFwugBPgfM4ELHHlYpXkD1hnGRN_N2plQk4CbVVqvZ2N_JRxVfOX63Tfay44xBHddy73Uqvo47C4gyye_WNbLcVWPOXuEXtq76r0oTCI5SM3matpAovtvubZHiZhRPTUc5zRPFn_AMHCg-lgOcotTBDElT_jkkiR5I_PGQXR6IXndIqvCfSmhu5kEw0deSS62JkUNb4JNjEBxGUxC_JMUkwSVbHL_dI8AxYk-KrcCbqGMiQE4H649pQO9qJgLcfwQLeXqxcJjLBA29nZ4dX637ENW9vwNtJeQm8_Vp_1pwga86QNTtpfJwojLZH4Kf7HpxQCoMd4SR6wrswKJ5-zQooLusuIp4QTs_4m1OJ6xWJofj2n3f8KekhA6z584rSLs7TSlSyu5KSofKotKZBaAwjOXrA_p_nPI1Ok3PWxQdhfgYFNwSuCArkovnGBhTzTMKhMij2hneXH3y9z_5eezfqfz5dUHz7NBRTvmp_yPhu4KGvs77KKnGgOj3l55TnxTk7jHVRVqyoepZSV16vVdGdBFHfs6Ivy6uUxUHVnPGCFTznnFV5dkxT0XFWCd7l52t-riBnNAmlj1rfpqN1w0F5v1Cd5ml2Tg9adKT9epRzbugV19movLgcXB1BSbcMHnKmlQ_-o0xQQVPdCu0pma1XQd0oRuYXP5KS4etIBhcfj4AvQ-EPi9P1GMLs4-bxFng7qDAu3VHaCXgb-7r_JbOzEQ28XdXEs-Iu91bzfwMAAP__YL8ZZQ">