<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/110798>110798</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-tidy false positive cppcoreguidelines assignment operator with explicit object parameters
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cgnitash
</td>
</tr>
</table>
<pre>
When using an assignment operator with explicit object parameters,
1. clang-tidy mistakes assignment operators as a copy-assignment operator.
2. The guideline for returning `*this` is too strict (returning self has the same semantics afaik).
```
struct S
{
S &operator=(this S& self, int)
{
return self;
}
};
```
clang-tidy gives
> Warning: operator=() should take 'S const&', 'S&&' or 'S' [cppcoreguidelines-c-copy-assignment-signature]
> 3 | S &operator=(this S& self, int)
> | ^
and
> warning: operator=() should always return '*this' [cppcoreguidelines-c-copy-assignment-signature]
> 5 | return self;
> | ^
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVEGPszgM_TXmYrVKQyFw4NBOp3-gK33nNLiQ_QJBcehs__0KSqfd2TmsZiUExHnPec-OrJlt0xNVkO0hOyR6jK0PlWl6GzW3ydnXt-pXSz2ObPsGdY93Skd9RD9Q0NEH_LCxRfprcNbYiP78J5mIgw66o0iBQb6BOIDY4WaNxum-WUVb37CzHPVv4u9yTkHUaPxwW32zvcYlo1zjHy1hM9qanO0JLz5goDiGfhIMuQC5i61lyAVaxug9cgzWRARZPIFM7oKtZowtIeuOkKnTfbSGUV-0_Q2yfBw6Jb0_85JjGE3E07Kp9os0PCHI_KEY0gPIYlKCJ5D5fCDIN7R9BFk-KC9sXGzcken-CTk8Tjp8hr9IeilyY6_ECyh9x1969gvpDv-pDGSJ3PrR1Tg1BUGqExrfcwSZg1ST1ik2r6YA-rAEFEK2N8NgfKDPRvDKrL50bzX96DgGguzwlISIKYJ6wx9UbOEjLgkge1825rfu69flhP74DwXQ7kPf-FH_2fz9Dv1_q9ki9Pvuftp5gCB7T-oqrcu01AlVGyVVkWVZUSRtlas6J5Vmm3RrLjrdqDwt0tLkqs7ICFMktpJCbjdCSKGyVBTrbU25qrUoSqrPStSwFdRp69bOXbu1D01imUeqNhuhyiJx-kyO59kg5fNKgZTTrAjVxFqdx4ZhK5zlyM880UZH1cs1vGjHhINnG-2V8F8l_MlcScbgqjbGgSHdgTyCPDY2tuN5bXwH8jipWT6rIfiJDfI4W2SQx8XltZJ_BwAA__8A545W">