This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCH for C++14 sized deallocation


On 12/15/2014 01:30 PM, Jason Merrill wrote:
This patch implements the last remaining language feature for C++14,
global sized deallocation.  C++ has always had sized deallocation at
class scope, but didn't for deletes that use the global operator delete.

The support can be controlled separately from the -std level with the
-fsized-deallocation flag (same as clang).

The compiler will warn about the unsized variant being defined without
the sized variant (or vice versa) with the -Wsized-deallocation flag,
which is also enabled by -Wextra.

This patch also adds -Wc++14-compat, which currently only warns about a
deallocation function with a second size_t parameter changing from being
a placement delete to a usual deallocation function.

Tested x86_64-pc-linux-gnu, applying to trunk.

I suppose we should also declare these functions in <new>.

Jason

commit d37df45bae7ad7afb1825dd294eefea0781b245f
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Oct 29 11:27:33 2015 -0400

    	* libsupc++/new: Declare sized deletes.

diff --git a/libstdc++-v3/libsupc++/new b/libstdc++-v3/libsupc++/new
index bd50b6c..0f6a05a 100644
--- a/libstdc++-v3/libsupc++/new
+++ b/libstdc++-v3/libsupc++/new
@@ -116,6 +116,12 @@ void operator delete(void*) _GLIBCXX_USE_NOEXCEPT
   __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__));
 void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
@@ -124,6 +130,12 @@ 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_sized_deallocation
+void operator delete(void*, std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
+  __attribute__((__externally_visible__));
+void operator delete[](void*, std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
+  __attribute__((__externally_visible__));
+#endif
 
 // Default placement versions of operator new.
 inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]