[clang] [clang][win] MSVC-compat: Use `__global_delete` wrapper in deleting destructors instead of directly referencing `::operator delete` (PR #188372)
Daniel Paoliello via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 8 11:50:05 PDT 2026
================
@@ -2069,6 +2072,12 @@ void CodeGenFunction::EmitCXXDeleteExpr(const CXXDeleteExpr *E) {
const Expr *Arg = E->getArgument();
Address Ptr = EmitPointerWithAlignment(Arg);
+ // If this delete expression uses global ::operator delete (not a
+ // class-specific one), note it so we emit __global_delete forwarding bodies.
+ if (!isa<CXXMethodDecl>(E->getOperatorDelete()) &&
+ CGM.getTarget().getCXXABI().isMicrosoft())
+ CGM.noteDirectGlobalDelete();
----------------
dpaoliello wrote:
Fixed: lined-up with MSVC's behavior where it requires an explicit global operator delete (with the leading `::` qualification) for a type with non-trivial destructor.
https://github.com/llvm/llvm-project/pull/188372
More information about the cfe-commits
mailing list