<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54674>54674</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Overload resolution fails with deleted destructor
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hpesoj
</td>
</tr>
</table>
<pre>
With Clang 15.0.0, this fails to compile:
```
template <bool B>
struct test {
~test() = delete;
~test() requires(B) {}
};
int main() {
test<true>{};
}
```
```
prog.cc:8:15: error: attempt to use a deleted function
test<true>{};
^
prog.cc:3:5: note: '~test' has been explicitly marked deleted here
~test() = delete;
```
This precludes real uses cases, such as this `std::optional`-like wrapper, where variant member with with a non-trivial destructor causes the defaulted destructor to be deleted:
```
#include <type_traits>
template <typename T>
struct opt
{
union {
char none;
T some;
};
opt() : none() {}
~opt() = default;
~opt() requires(!std::is_trivially_destructible_v<T>) { some.~T(); }
};
```
Note that the latest GCC does not have the same problem.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVE1zmzAQ_TXishMGkA3xgYM_kt7ai2d69AhYG6UyopJw6n_flWxsx3E7LQMCVtJ-vPdWlW6O5XfpWlgq0e0gncZJnLBsCa6VFrZCKgtOQ633vVTI-JwlK5aMY56c7_DrcN8r4RAYX1ZaK1gw_nKass4MtQOH1gErFicj0MWKF29k2TPLZrRxBQ0qdBTpj4sM_hykQUu_i7CJ_BWrc0b0Me48jbJzsBeyGyPcBg9O-ZJyQ5_pyc9l-8XnxyofGnujd3FdEz7P9KRTGgCN0cZ_COeRcR7HwSKIc4kNbIeudlJ3_5gRfLjY9OU-NqcnhO60R3AOLCsu2BXQCgsVYgf4q1eylk4dCRrzgzIZM2rR4H-Q8xCatVdOb7BWQ4OW6BLK122hFtaztgQ71C1QMkFjtNu6xiuLz3Xv4RCKbE9K_kB4N6Lv0fhN7z43OAgjhacU9xUaePfSDYOgorsnZ-RBUjwKHBSnDUUNwV2LZN2KQblQ72WeWKlwBODvAmcZl10oy0vcHXvcOCOksxedf24Ev6oTe4T1fTNQsaPSbggeOkLgo0z9VbfC-ArxkxrWYPX-vl_uu8BbfbyRyfnJ17UnLmK_Jf92x2pE774zr4tuGpNl6YVUaTdnWtRxMwIvK4WbA-ETYDklEQqJyeX65JAiwePOfiS7r6R5Ylm4QLWHn86aL8slNJrop44g_R8wTFrPB7UN5bCPo6bkzYzPROSoI7D8dkCjtGioHKvV4AV5PgeDzsZOuSooGowqW-d66-vNXune0cqhiunUpB-lDuPriYK-YU2AvUprBw_V63SSF5OoLXNMZ0lSNNW2TvI03SYJGZrtbMJ5laRpHSlRobIlmy7YdBXJMkuyLOE8TScTnvF4UoiiKaZFkW_z5zznbJIgHXwq9oFjbXaRKUMO1bCzNKmkdfY6KayVuw5x9C8G12pTtj2h8BaFbMuQ6m-8Ysvn">