llvm-project
llvm-project copied to clipboard
clang misses useful diagnostic for private `operator delete` in template base class
Consider the following code:
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.