From cbba348a835ef0e636d6e2015b4ef0d11bc476a4 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 26 Jul 2021 16:55:36 +1000 Subject: [PATCH] always inline custom operator new/delete to avoid spurious warnings GCC 11 warns incorrectly about mismatched new/delete because it auto inlines one but not the other, force inline those function to fix that. --- src/memory.hh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/memory.hh b/src/memory.hh index aa71776a..02df470e 100644 --- a/src/memory.hh +++ b/src/memory.hh @@ -150,29 +150,35 @@ template struct UseMemoryDomain { static constexpr MemoryDomain Domain = d; + + [[gnu::always_inline]] static void* operator new(size_t size) { on_alloc(Domain, size); return ::operator new(size); } + [[gnu::always_inline]] static void* operator new[](size_t size) { on_alloc(Domain, size); return ::operator new[](size); } + [[gnu::always_inline]] static void* operator new(size_t size, void* ptr) { return ::operator new(size, ptr); } + [[gnu::always_inline]] static void operator delete(void* ptr, size_t size) { on_dealloc(Domain, size); ::operator delete(ptr); } + [[gnu::always_inline]] static void operator delete[](void* ptr, size_t size) { on_dealloc(Domain, size);