https://gcc.gnu.org/g:67434fec24bef0faeec0eb402f82ca7e43a4a112
commit r13-8804-g67434fec24bef0faeec0eb402f82ca7e43a4a112 Author: Jonathan Wakely <jwak...@redhat.com> Date: Wed May 22 10:32:43 2024 +0100 libstdc++: Guard use of sized deallocation [PR114940] Clang does not enable -fsized-deallocation by default, which means it can't compile our <stacktrace> header. Make the __cpp_lib_generator macro depend on the compiler-defined __cpp_sized_deallocation macro, and change <stacktrace> to use unsized deallocation when __cpp_sized_deallocation isn't defined. libstdc++-v3/ChangeLog: PR libstdc++/114940 * include/std/stacktrace (_GLIBCXX_SIZED_DELETE): New macro. (basic_stacktrace::_Impl::_M_deallocate): Use it. (cherry picked from commit b2fdd508d7e63158e9d2a6dd04f901d02900def3) Diff: --- libstdc++-v3/include/std/stacktrace | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libstdc++-v3/include/std/stacktrace b/libstdc++-v3/include/std/stacktrace index 8f09467d751..3d8a085a6a9 100644 --- a/libstdc++-v3/include/std/stacktrace +++ b/libstdc++-v3/include/std/stacktrace @@ -600,6 +600,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #else # define _GLIBCXX_OPERATOR_NEW ::operator new # define _GLIBCXX_OPERATOR_DELETE ::operator delete +#endif + +#if __cpp_sized_deallocation +# define _GLIBCXX_SIZED_DELETE(T, p, n) \ + _GLIBCXX_OPERATOR_DELETE((p), (n) * sizeof(T)) +#else +# define _GLIBCXX_SIZED_DELETE(T, p, n) _GLIBCXX_OPERATOR_DELETE(p) #endif // Precondition: _M_frames == nullptr && __n != 0 @@ -641,8 +648,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION if (_M_capacity) { if constexpr (is_same_v<allocator_type, allocator<value_type>>) - _GLIBCXX_OPERATOR_DELETE (static_cast<void*>(_M_frames), - _M_capacity * sizeof(value_type)); + _GLIBCXX_SIZED_DELETE(value_type, + static_cast<void*>(_M_frames), + _M_capacity); else __alloc.deallocate(_M_frames, _M_capacity); _M_frames = nullptr; @@ -650,6 +658,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } } +#undef _GLIBCXX_SIZED_DELETE #undef _GLIBCXX_OPERATOR_DELETE #undef _GLIBCXX_OPERATOR_NEW