<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/120923>120923</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang-tidy] Check request: detect suspicious deleted constructor and assignment operator
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
denzor200
</td>
</tr>
</table>
<pre>
In C++20 mode it becomes possible to use `auto` in a function parameter declaration, so thus it's possible to write strange code like this:
```
struct A {
A() = default;
A(const auto& other) = delete;
A& operator=(const auto& other) = delete;
};
```
These two deleted functions don't make sense indeed and they look suspicious - looks like someone tried to make `A` noncopyable.
The root of the problem is that `A` still remains copyable, which might be bugproned.
In my opinion it's easy to make such typo in the code, especially if you are following guideline that orders you to always use `auto` everywhere it's possible.
Suppose we need a check that will automatically provide the fix for the code above:
```
struct A {
A() = default;
A(const A& other) = delete;
A& operator=(const A& other) = delete;
};
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVMGO67YO_RplQ0zgyIkzXniRmUGAt379AVlibHVk0RWppO7XF3Jyc-deFEVRFDBgQyaPDg8PaZj9EBE7dXhTh4-NyTJS6hzGPyjpqtr05JZOVaf_RXhX-k3pN13BRA7BC_RoaUKGmZh9HxCEIDOCaiqThVRTgY9g4JKjFU8RZpPMhIIJHNpgkimnSr8DE8iYGbwoffwR8Ja8ILAkEwcEW64O_hNBRs-qPqnqpJrq8VQnlpStwAnU8U1VJwCAk9KvSreg6g9weDE5iKq__rQUWWBlrBsgGTF9jw8o-EN4AzRjMkJJ1R__PFsdPx4fX9j-MiIjyI0eoe4pFYMryhwFJvOJwBgZwUeH6MBEBzLiAoHoEzjz7K2nzPCynvBdH6YJKSJI8uiKkCuQalYGEClamhfTB9zCnQkkIgG6FGyYE_UBJ_AMMhp55rH4ECDhZHxk-AZRWngbvR1h8sNYjAF9HuZEEd327p5pAZp9LC54NBkNL09enO0IssxUHFMIlEYXWOQZrTchLOAvsFAGkxAuFALdfBxgyN5h8KXQwpOSw8RrnBCYcDML_-xJvGJabiMm_Nlvhev_8zwTI9wQ4qo22BHt5x3-VqovOJMRb1dWc6Krd7iSvvjf4ULpWQCYnq74X7r09O8t-vepf-nPjetq19at2WC3O9b7drfTr4fN2PXOtXvtdIuHY1Mbh82xNtYZ17RVvX9tNr7Tld7vtNa63r9Wh2170FV7rJvdTpu6Nju1r4qJwjaE67SlNGw8c8Zup6tW15tgegy8riWtbTBxeBHvFqV1WVOpK1kvfR5Y7avgWfg7jngJ60L7knb4gPe1iwl_y8ii6hM4FLTydX6-DeGqV-kQpXXY7ltywihPYTc5hW4UmdcdpM9KnwcvY-63lialz4XN4_UyJ_oVrSh9Xktkpc-PKq-d_jMAAP__QCrDzQ">