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.
This commit is contained in:
Maxime Coste 2021-07-26 16:55:36 +10:00
parent 15aa4fe137
commit cbba348a83

View File

@ -150,29 +150,35 @@ template<MemoryDomain d>
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);