From 0b8d6b8309b33c822bbda1a2a3cd5f6f358bc2fb Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Tue, 4 Aug 2026 09:59:42 +0200 Subject: [PATCH] Fix compilation with gcc16 Do not redefine the standard placement new/delete operators tools.h defined the placement forms of operator new/delete itself instead of pulling them in from . That only works as long as no standard library header defining them has been included before. As of GCC 16, libstdc++ includes from , which cube.h drags in via -> , so the definitions in tools.h now collide with the ones from the standard library and the build fails: In file included from shared/cube.h:57: shared/tools.h:38:14: error: redefinition of 'void* operator new(size_t, void*)' 38 | inline void *operator new(size_t, void *p) { return p; } | ^~~~~~~~ /usr/include/c++/16/new:168:7: note: 'void* operator new(std::size_t, void*)' previously defined here Include and drop the hand-written definitions. The standard ones are inline and behave identically - and, unlike ours, are constexpr where the standard requires it. The custom operator new(size_t, bool) overloads are not affected. --- src/shared/tools.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/shared/tools.h b/src/shared/tools.h index e7f5783c2..f8c1c887b 100644 --- a/src/shared/tools.h +++ b/src/shared/tools.h @@ -3,6 +3,8 @@ #ifndef _TOOLS_H #define _TOOLS_H +#include // for the placement forms of operator new/delete + #ifdef NULL #undef NULL #endif @@ -64,10 +66,6 @@ static inline int popcount(uint n) void *operator new(size_t, bool); void *operator new[](size_t, bool); -inline void *operator new(size_t, void *p) { return p; } -inline void *operator new[](size_t, void *p) { return p; } -inline void operator delete(void *, void *) {} -inline void operator delete[](void *, void *) {} #ifdef swap #undef swap