<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/98889>98889</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang misses useful diagnostic for private `operator delete` in template base class
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Rush10233
</td>
</tr>
</table>
<pre>
Consider the following code:
```c++
template <typename T>struct QCachedT{
void operator delete(void *, T *) {}
};
struct thing_t :private QCachedT<int>{
};
int main() {
auto thing=new thing_t;
//error
//delete thing_t;
}
```
Clang will not report any error for the private `delete` operator until it is explicitly called. That seems inappropriate because clang will error immediately after using the `new` operator if the base class `QCachedT` is non-template instead. As a comparison, GCC always provides an error right after the `new` statement is created no matter whether `QCachedT` is a template class or not.
[https://godbolt.org/z/r71e3WT5h](https://godbolt.org/z/r71e3WT5h)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMlEGP-jYQxT-NcxktSpyEhEMOC_zpuRVSj9XgDIkrx47sCZR--soJu2Q5VYoAmed5vxm_GEPQnSVqRLkX5THBiXvnmz-m0GepzPPk4tpHc3A26JY8cE9wdca4u7YdKNeSyD9FehTp1-c2XR4l5D4-8yrTMBpkApEf-DGSxYHgLPJfgf2kGH4_oOqpPYtqD8sOAICb0y24kTyy89CSISYh63lZyE8hD3BefuxAVHtRHZ8M1VHk-zXV04Z7bbu_GET-OXp9i0DfzvlBWxb5r1ho3c9cC2C9pi3DgNoKWT-tI-0KHCd2i5nIj5buX8ZzpbVQyJOQJ_Le-ffFpd3VzhfPz0GvyQ4GbQd3bQxYx-BpdJ4B7QNmD7i65Qi_uhfb9DnWbfqa9GRZG9AMOgD9MxqtNJsHKDSG2g2ce2QIREMAbXEcvRu9jtUupHAKBOpFsdjqYaA2SswD8MrkYQoxPxElMli6R4AXgb7O_11wqRZCVH0f1TaNZNbZj-9caRuYsN3AZwAE5YYRvQ7Oxoz8djgAmjs-Aoze3XRLAdA-0bzuen5CRcsXTWBkGsjOY1CekKkF62BAjuJ7T9yTfweLYoRvrgXe-Xgcmx-5Kvc98xji6zOfd-faizO8cb4T8vSvkCdfZZT_eS57UR6FrP-_XO6StsnbXb7DhJqsklla5HWVJX1TVNtrta2z-qpUVlaFpDYtVFRgjdk1S3QjU1mkVVZmWVHk2YZKiSqliyxRSSq2okhpQG02xtyGaJ_oECZqdnVd7xKDFzJhvkyknHMgpIz3im-i_uMydUEUqdGBw6sCazbULLEZdAgUYAp0nQy0GjvrAms1Z3eV2_d7IYbCvgb_ik4yedO8DU9zP102yg1CniLF8-tj9O5vUizkaW4qCHla-ro18r8AAAD__zEinl0">