<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/76064>76064</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[cppcoreguidelines-special-member-functions] Spiritually false positive for `operator=(T)`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Eisenwave
</td>
</tr>
</table>
<pre>
Consider the example (https://godbolt.org/z/fPP6cnbYv):
```cpp
struct MyClass {
MyClass(const MyClass&);
MyClass(MyClass&&);
~MyClass();
MyClass& operator=(MyClass other) noexcept;
};
```
```none
<source>:1:8: warning: class 'MyClass' defines a destructor, a copy constructor, a copy assignment operator and a move constructor but does not define a move assignment operator [cppcoreguidelines-special-member-functions]
1 | struct MyClass {
| ^
```
Technically, clang-tidy is right, and `MyClass` does not have a move assignment operator.
However, this is spiritually a false positive because `operator=(MyClass)` accepts both rvaues and lvalues and is acting as a "unified" assignment operator. clang-tidy should not emit a diagnostic in the event that the copy assignment operator has a by-value parameter, or this behavior should be configurable somehow.
See [Stack Overflow/clang-tidy does not recognize unifying assignment operator as move assigment](https://stackoverflow.com/q/77692186/5740428) for more discussion.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVcGO4zYM_RrlQiRQ5NiODz7MTCbopegCs5ceZZm21cqSK8rOZg_99kJ2MsnOZgpsECQSTYp8j0-0JNKtRSxZ-szSw0qOoXO-fNWE9iQnXFWuPpcvzpKu0UPoEPCb7AeDwMS-C2EgljwxcWTi2Lq6ciZsnG-ZOH5n4th8-ZIpW_05MVFEN35g_IllfPmqYVgsFPyoAvx-fjGSCFj-vNgB4GpkYq-cpXDbZ_OZDz3vfX50-_fm9Gl4Bm5AL4PzLDncTgMXOvRMFGAdflM4hPdwlh9u6yu6D1vrLF5MyQu50StkyStLnrYsedqz5AlO0ltt27hUCw8ify8qhxobbZFAQo0LYc4z8QIS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