diff mbox series

new(nothrow) is malloc-like

Message ID alpine.DEB.2.02.1808241805300.2696@stedding.saclay.inria.fr
State New
Headers show
Series new(nothrow) is malloc-like | expand

Commit Message

Marc Glisse Aug. 24, 2018, 4:25 p.m. UTC
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.glisse@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.

Comments

Jonathan Wakely Aug. 24, 2018, 4:50 p.m. UTC | #1
On 24/08/18 18:25 +0200, Marc Glisse wrote:
>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.glisse@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.

OK, thanks.
diff mbox series

Patch

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