================
@@ -3768,6 +3768,28 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool 
UseGlobal,
     DeclarationName DeleteName = Context.DeclarationNames.getCXXOperatorName(
                                       ArrayForm ? OO_Array_Delete : OO_Delete);
 
+    // C++20 [expr.delete]p6: If the value of the operand of the delete-
+    // expression is not a null pointer value and the selected deallocation
+    // function (see below) is not a destroying operator delete, the delete-
+    // expression will invoke the destructor (if any) for the object or the
+    // elements of the array being deleted.
+    //
+    // This means we should not look at the destructor for a destroying
+    // delete operator, as that destructor is never called, unless the
+    // destructor is virtual (see [expr.delete]p8.1) because then the
+    // selected operator depends on the dynamic type of the pointer.
----------------
AaronBallman wrote:

Oof, good catch! Also, thank you for reporting this to Core.

Do you think I should make any changes here as part of this PR? I saw your 
comment on 
https://github.com/llvm/llvm-project/pull/118687#issuecomment-2521239072, I 
could handle that in a follow-up (probably tomorrow, so if you want me to 
revert those changes, I can). It's not quite clear to me whether this is a 
"wait for Core because we don't want behavioral churn" situation or not.

https://github.com/llvm/llvm-project/pull/118800
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to