https://gcc.gnu.org/g:2620e3727d9559ec03f9f967ecb68ed2e076a342
commit r15-3807-g2620e3727d9559ec03f9f967ecb68ed2e076a342 Author: Jason Merrill <ja...@redhat.com> Date: Mon Sep 9 11:20:02 2024 -0400 libstdc++: operator new/delete are transaction_safe With the changes to #pragma system_header, g++.dg/tm/pr46270.C was failing because <new> didn't implement the N4514 change to [new.delete] that says "The library versions of the global allocation and deallocation functions are declared transaction_safe (8.3.5 dcl.fct)." We already have the _GLIBCXX_TXN_SAFE macro, just need to add it. libstdc++-v3/ChangeLog: * libsupc++/new: Add _GLIBCXX_TXN_SAFE. Diff: --- libstdc++-v3/libsupc++/new | 56 +++++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/libstdc++-v3/libsupc++/new b/libstdc++-v3/libsupc++/new index b530bd1100df..e8b00505cf1e 100644 --- a/libstdc++-v3/libsupc++/new +++ b/libstdc++-v3/libsupc++/new @@ -132,49 +132,63 @@ namespace std * Placement new and delete signatures (take a memory address argument, * does nothing) may not be replaced by a user's program. */ -_GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) +_GLIBCXX_NODISCARD void* operator new(std::size_t) + _GLIBCXX_TXN_SAFE _GLIBCXX_THROW (std::bad_alloc) __attribute__((__externally_visible__)); -_GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) +_GLIBCXX_NODISCARD void* operator new[](std::size_t) + _GLIBCXX_TXN_SAFE _GLIBCXX_THROW (std::bad_alloc) __attribute__((__externally_visible__)); -void operator delete(void*) _GLIBCXX_USE_NOEXCEPT +void operator delete(void*) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); -void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT +void operator delete[](void*) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); #if __cpp_sized_deallocation -void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT +void operator delete(void*, std::size_t) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); -void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT +void operator delete[](void*, std::size_t) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); #endif -_GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT +_GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); -_GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT +_GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); -void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT +void operator delete(void*, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); -void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT +void operator delete[](void*, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); #if __cpp_aligned_new _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) + _GLIBCXX_TXN_SAFE __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); -void operator delete(void*, std::align_val_t) +void operator delete(void*, std::align_val_t) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); void operator delete(void*, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) + _GLIBCXX_TXN_SAFE __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); -void operator delete[](void*, std::align_val_t) +void operator delete[](void*, std::align_val_t) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); void operator delete[](void*, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); #if __cpp_sized_deallocation -void operator delete(void*, std::size_t, std::align_val_t) +void operator delete(void*, std::size_t, std::align_val_t) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); -void operator delete[](void*, std::size_t, std::align_val_t) +void operator delete[](void*, std::size_t, std::align_val_t) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); #endif // __cpp_sized_deallocation #endif // __cpp_aligned_new @@ -187,17 +201,23 @@ void operator delete[](void*, std::size_t, std::align_val_t) // Default placement versions of operator new. _GLIBCXX_NODISCARD _GLIBCXX_PLACEMENT_CONSTEXPR -void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT +void* operator new(std::size_t, void* __p) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT { return __p; } _GLIBCXX_NODISCARD _GLIBCXX_PLACEMENT_CONSTEXPR -void* operator new[](std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT +void* operator new[](std::size_t, void* __p) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT { return __p; } #undef _GLIBCXX_PLACEMENT_CONSTEXPR // Default placement versions of operator delete. -inline void operator delete (void*, void*) _GLIBCXX_USE_NOEXCEPT { } -inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { } +inline void operator delete (void*, void*) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT +{ } +inline void operator delete[](void*, void*) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT +{ } //@} } // extern "C++"