* new(nothrow) is malloc-like
@ 2018-08-24 16:25 Marc Glisse
2018-08-24 16:50 ` Jonathan Wakely
0 siblings, 1 reply; 2+ messages in thread
From: Marc Glisse @ 2018-08-24 16:25 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: TEXT/PLAIN, Size: 637 bytes --]
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.
--
Marc Glisse
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: TEXT/x-diff; name=malloc.patch, Size: 2777 bytes --]
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: new(nothrow) is malloc-like
2018-08-24 16:25 new(nothrow) is malloc-like Marc Glisse
@ 2018-08-24 16:50 ` Jonathan Wakely
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2018-08-24 16:50 UTC (permalink / raw)
To: Marc Glisse; +Cc: libstdc++, gcc-patches
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-08-24 16:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-24 16:25 new(nothrow) is malloc-like Marc Glisse
2018-08-24 16:50 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).