[clang] [C++20] Destroying delete and deleted destructors (PR #118800)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 5 06:12:03 PST 2024
================
@@ -23,3 +30,14 @@ struct alignas(Align) B {
};
void f(B<__STDCPP_DEFAULT_NEW_ALIGNMENT__> *p) { delete p; }
void f(B<__STDCPP_DEFAULT_NEW_ALIGNMENT__ * 2> *p) { delete p; } // expected-error {{deleted}}
+
+// Ensure that a deleted destructor is acceptable when the selected overload
+// for operator delete is a destroying delete. See the comments in GH118660.
+struct S {
+ ~S() = delete;
+ void operator delete(S *, std::destroying_delete_t) noexcept {}
+};
+
+void foo(S *s) {
+ delete s; // Was rejected, is intended to be accepted.
+}
----------------
cor3ntin wrote:
can you add a test with a private destructor?
(I found this unresolved issue https://cplusplus.github.io/CWG/issues/2889.html that is tangentially relevant )
https://github.com/llvm/llvm-project/pull/118800
More information about the cfe-commits
mailing list