Fix compilation with gcc16 - #1719
Open
bmwiedemann wants to merge 1 commit into
Open
Conversation
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 <new>. That only works as long as no
standard library header defining them has been included before.
As of GCC 16, libstdc++ includes <new> from <bits/stl_iterator.h>,
which cube.h drags in via <math.h> -> <cmath>, 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 <new> 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
<new>. That only works as long as no standard library header defining them has been included before.As of GCC 16, libstdc++ includes
<new>from<bits/stl_iterator.h>, which cube.h drags in via<math.h> -> <cmath>, so the definitions in tools.h now collide with the ones from the standard library and the build fails:Include
<new>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 customoperator new(size_t, bool)overloads are not affected.