Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang does not realize inaccessible user-defined operator delete until it is called #121645

Open
wangbo15 opened this issue Jan 4, 2025 · 1 comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" diverges-from:edg Does the clang frontend diverge from edg compiler diverges-from:gcc Does the clang frontend diverge from gcc on this issue diverges-from:msvc Does the clang frontend diverge from msvc on this issue

Comments

@wangbo15
Copy link

wangbo15 commented Jan 4, 2025

Consider the following code:

class QCachedT
{
  static void operator delete(void *, int) {}
};

int main() {
     auto a = new QCachedT;
     //QCachedT::operator delete(a, 10);     
}

It appears that clang does not complain about anything about the private operator delete of QcacheT when it is dynamically instantiated. Only when the operator is explicitly called will the compiler reject the code. However, there is no need to do so in GCC, EDG, and MSVC:

https://godbolt.org/z/rvs1bjavh

Considering that clang will also reject the code without explicit calling of operator delete when it defaults, it seems to be more like a bug of clang:

class QCachedT
{
  static void operator delete(void *){} 
};

int main() {
     auto a = new QCachedT;    
}

https://godbolt.org/z/8oso11haf

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Jan 4, 2025
@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" diverges-from:gcc Does the clang frontend diverge from gcc on this issue diverges-from:msvc Does the clang frontend diverge from msvc on this issue diverges-from:edg Does the clang frontend diverge from edg compiler and removed clang Clang issues not falling into any other category labels Jan 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 4, 2025

@llvm/issue-subscribers-clang-frontend

Author: Bo Wang (wangbo15)

Consider the following code:
class QCachedT
{
  static void operator delete(void *, int) {}
};

int main() {
     auto a = new QCachedT;
     //QCachedT::operator delete(a, 10);     
}

It appears that clang does not complain about anything about the private operator delete of QcacheT when it is dynamically instantiated. Only when the operator is explicitly called will the compiler reject the code. However, there is no need to do so in GCC, EDG, and MSVC:

https://godbolt.org/z/rvs1bjavh

Considering that clang will also reject the code without explicit calling of operator delete when it defaults, it seems to be more like a bug of clang:

class QCachedT
{
  static void operator delete(void *){} 
};

int main() {
     auto a = new QCachedT;    
}

https://godbolt.org/z/8oso11haf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" diverges-from:edg Does the clang frontend diverge from edg compiler diverges-from:gcc Does the clang frontend diverge from gcc on this issue diverges-from:msvc Does the clang frontend diverge from msvc on this issue
Projects
None yet
Development

No branches or pull requests

3 participants