Skip to content

Commit a8637d8

Browse files
Merge pull request ceph#64969 from edwinzrodriguez/ceph-wip-72478
common/async:: Update delete operator in CompletionImpl
2 parents f4d8694 + 84d2aad commit a8637d8

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/common/async/completion.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,17 @@ class CompletionImpl final : public Completion<void(Args...), T> {
246246
std::forward<TArgs>(args)...)};
247247
}
248248

249-
static void operator delete(void *p) {
250-
static_cast<CompletionImpl*>(p)->destroy();
249+
// C++20 destroying delete.
250+
// When this overload is selected by `delete ptr`, the compiler does NOT call
251+
// ~CompletionImpl(). We must do the full teardown here. We route through
252+
// destroy() so that:
253+
// - the completion’s custom lifecycle (defer/dispatch/post) is honored,
254+
// - the object’s destructor is invoked, and
255+
// - deallocation is performed using the matching allocator (RebindAlloc2).
256+
// Keep this function noexcept; destroy() is responsible for both destruction
257+
// and allocator-aware deallocation.
258+
static void operator delete(CompletionImpl* ptr, std::destroying_delete_t) noexcept {
259+
ptr->destroy();
251260
}
252261
};
253262

0 commit comments

Comments
 (0)