Hello,

this makes the throwing and non-throwing versions of operator new more consistent with respect to __attribute__((malloc)). The throwing versions are already unconditionally declared with DECL_IS_MALLOC = 1 in the front-end.

Bootstrap+regtest on powerpc64le-unknown-linux-gnu. I manually checked that the attribute has an effect.

2018-08-25  Marc Glisse  <marc.gli...@inria.fr>

        PR libstdc++/86822
        * libsupc++/new (operator new(size_t, nothrow_t), operator
        new[](size_t, nothrow_t), operator new(size_t, align_val_t, nothrow_t),
        operator new[](size_t, align_val_t, nothrow_t)): Add malloc attribute.

--
Marc Glisse
Index: libstdc++-v3/libsupc++/new
===================================================================
--- libstdc++-v3/libsupc++/new	(revision 263834)
+++ libstdc++-v3/libsupc++/new	(working copy)
@@ -130,40 +130,40 @@ void operator delete(void*) _GLIBCXX_USE
   __attribute__((__externally_visible__));
 void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT
   __attribute__((__externally_visible__));
 #if __cpp_sized_deallocation
 void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
   __attribute__((__externally_visible__));
 void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
   __attribute__((__externally_visible__));
 #endif
 void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
-  __attribute__((__externally_visible__));
+  __attribute__((__externally_visible__, __malloc__));
 void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
-  __attribute__((__externally_visible__));
+  __attribute__((__externally_visible__, __malloc__));
 void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
   __attribute__((__externally_visible__));
 void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
   __attribute__((__externally_visible__));
 #if __cpp_aligned_new
 void* operator new(std::size_t, std::align_val_t)
   __attribute__((__externally_visible__));
 void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
-  _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
+  _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __malloc__));
 void operator delete(void*, std::align_val_t)
   _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
 void operator delete(void*, std::align_val_t, const std::nothrow_t&)
   _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
 void* operator new[](std::size_t, std::align_val_t)
   __attribute__((__externally_visible__));
 void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
-  _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
+  _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __malloc__));
 void operator delete[](void*, std::align_val_t)
   _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
 void operator delete[](void*, std::align_val_t, const std::nothrow_t&)
   _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
 #if __cpp_sized_deallocation
 void operator delete(void*, std::size_t, std::align_val_t)
   _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
 void operator delete[](void*, std::size_t, std::align_val_t)
   _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__));
 #endif // __cpp_sized_deallocation

Reply via email to