[libcxx] r237592 - Fix for LWG Issue 2458: N3778 and new library deallocation signatures.

Marshall Clow mclow.lists at gmail.com
Mon May 18 10:48:45 PDT 2015


Author: marshall
Date: Mon May 18 12:48:45 2015
New Revision: 237592

URL: http://llvm.org/viewvc/llvm-project?rev=237592&view=rev
Log:
Fix for LWG Issue 2458: N3778 and new library deallocation signatures.

Removed:
    libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_nothrow_replace.pass.cpp
    libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_nothrow_replace.pass.cpp
Modified:
    libcxx/trunk/include/new
    libcxx/trunk/src/new.cpp

Modified: libcxx/trunk/include/new
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/new?rev=237592&r1=237591&r2=237592&view=diff
==============================================================================
--- libcxx/trunk/include/new (original)
+++ libcxx/trunk/include/new Mon May 18 12:48:45 2015
@@ -52,16 +52,12 @@ void* operator new(std::size_t size, con
 void  operator delete(void* ptr) noexcept;                              // replaceable
 void  operator delete(void* ptr, std::size_t size) noexcept;            // replaceable, C++14
 void  operator delete(void* ptr, const std::nothrow_t&) noexcept;       // replaceable
-void  operator delete(void* ptr, std::size_t size,
-                      const std::nothrow_t&) noexcept;                  // replaceable, C++14
 
 void* operator new[](std::size_t size);                                 // replaceable
 void* operator new[](std::size_t size, const std::nothrow_t&) noexcept; // replaceable
 void  operator delete[](void* ptr) noexcept;                            // replaceable
 void  operator delete[](void* ptr, std::size_t size) noexcept;          // replaceable, C++14
 void  operator delete[](void* ptr, const std::nothrow_t&) noexcept;     // replaceable
-void  operator delete[](void* ptr, std::size_t size,
-                        const std::nothrow_t&) noexcept;                // replaceable, C++14
 
 void* operator new  (std::size_t size, void* ptr) noexcept;
 void* operator new[](std::size_t size, void* ptr) noexcept;
@@ -142,7 +138,6 @@ _LIBCPP_NEW_DELETE_VIS void  operator de
 _LIBCPP_NEW_DELETE_VIS void  operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
 #if defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER >= 14
 _LIBCPP_NEW_DELETE_VIS void  operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
-_LIBCPP_NEW_DELETE_VIS void  operator delete(void* __p, std::size_t __sz, const std::nothrow_t&) _NOEXCEPT;
 #endif
 
 _LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz)
@@ -155,7 +150,6 @@ _LIBCPP_NEW_DELETE_VIS void  operator de
 _LIBCPP_NEW_DELETE_VIS void  operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
 #if defined(_LIBCPP_BUILDING_NEW) || _LIBCPP_STD_VER >= 14
 _LIBCPP_NEW_DELETE_VIS void  operator delete[](void* __p, std::size_t __sz) _NOEXCEPT;
-_LIBCPP_NEW_DELETE_VIS void  operator delete[](void* __p, std::size_t __sz, const std::nothrow_t&) _NOEXCEPT;
 #endif
 
 inline _LIBCPP_INLINE_VISIBILITY void* operator new  (std::size_t, void* __p) _NOEXCEPT {return __p;}

Modified: libcxx/trunk/src/new.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/new.cpp?rev=237592&r1=237591&r2=237592&view=diff
==============================================================================
--- libcxx/trunk/src/new.cpp (original)
+++ libcxx/trunk/src/new.cpp Mon May 18 12:48:45 2015
@@ -140,13 +140,6 @@ operator delete(void* ptr, size_t) _NOEX
 
 _LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
 void
-operator delete(void* ptr, size_t, const std::nothrow_t& nt) _NOEXCEPT
-{
-    ::operator delete(ptr, nt);
-}
-
-_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
-void
 operator delete[] (void* ptr) _NOEXCEPT
 {
     ::operator delete(ptr);
@@ -166,13 +159,6 @@ operator delete[] (void* ptr, size_t) _N
     ::operator delete[](ptr);
 }
 
-_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS
-void
-operator delete[] (void* ptr, size_t, const std::nothrow_t& nt) _NOEXCEPT
-{
-    ::operator delete[](ptr, nt);
-}
-
 #endif // !__GLIBCXX__
 
 namespace std

Removed: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_nothrow_replace.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_nothrow_replace.pass.cpp?rev=237591&view=auto
==============================================================================
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_nothrow_replace.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array_nothrow_replace.pass.cpp (removed)
@@ -1,109 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// test nothrow sized operator delete[] replacement.
-
-// Note that sized delete operator definitions below are simply ignored
-// when sized deallocation is not supported, e.g., prior to C++14.
-
-// UNSUPPORTED: sanitizer-new-delete
-
-#include <new>
-#include <cstddef>
-#include <cstdlib>
-#include <cassert>
-#include <limits>
-
-int unsized_delete_called = 0;
-int unsized_delete_nothrow_called = 0;
-int sized_delete_called = 0;
-int sized_delete_nothrow_called = 0;
-
-void operator delete[](void* p) throw()
-{
-    ++unsized_delete_called;
-    std::free(p);
-}
-
-void operator delete[](void* p, const std::nothrow_t&) throw()
-{
-    ++unsized_delete_nothrow_called;
-    std::free(p);
-}
-
-void operator delete[](void* p, std::size_t) throw()
-{
-    ++sized_delete_called;
-    std::free(p);
-}
-
-void operator delete[](void* p, std::size_t, const std::nothrow_t&) throw()
-{
-    ++sized_delete_nothrow_called;
-    std::free(p);
-}
-
-int new_handler_called = 0;
-
-void new_handler()
-{
-    ++new_handler_called;
-    std::set_new_handler(0);
-}
-
-bool A_constructed = false;
-
-struct A
-{
-    A() {A_constructed = true;}
-    ~A() {A_constructed = false;}
-};
-
-struct BadA : public A {
-    BadA() { throw std::bad_alloc(); }
-};
-
-int main()
-{
-    std::set_new_handler(new_handler);
-    try
-    {
-        void*volatile vp = operator new [] (std::numeric_limits<std::size_t>::max(), std::nothrow);
-        assert(new_handler_called == 1);
-        assert(vp == 0);
-    }
-    catch (...)
-    {
-        assert(false);
-    }
-    try
-    {
-        A* ap = new(std::nothrow) BadA [3];
-        assert(false);
-    }
-    catch (...)
-    {
-        assert(!A_constructed);
-#if _LIBCPP_STD_VER >= 14
-        // FIXME: Do we need a version of [Expr.Delete]#10 for nothrow
-        // deallocation functions (selecting sized ones whenever available)?
-        // It is not required by the standard. If it were, the following would
-        // be the expected behaviour (instead of the current one):
-        //   assert(!unsized_delete_nothrow_called);
-        //   assert(sized_delete_nothrow_called == 1);
-        assert(unsized_delete_nothrow_called == 1);
-        assert(!sized_delete_nothrow_called);
-#else // if _LIBCPP_STD_VER < 14
-        assert(unsized_delete_nothrow_called == 1);
-        assert(!sized_delete_nothrow_called);
-#endif
-        assert(!unsized_delete_called);
-        assert(!sized_delete_called);
-    }
-}

Removed: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_nothrow_replace.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_nothrow_replace.pass.cpp?rev=237591&view=auto
==============================================================================
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_nothrow_replace.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_nothrow_replace.pass.cpp (removed)
@@ -1,109 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-// test nothrow sized operator delete replacement.
-
-// Note that sized delete operator definitions below are simply ignored
-// when sized deallocation is not supported, e.g., prior to C++14.
-
-// UNSUPPORTED: sanitizer-new-delete
-
-#include <new>
-#include <cstddef>
-#include <cstdlib>
-#include <cassert>
-#include <limits>
-
-int unsized_delete_called = 0;
-int unsized_delete_nothrow_called = 0;
-int sized_delete_called = 0;
-int sized_delete_nothrow_called = 0;
-
-void operator delete(void* p) throw()
-{
-    ++unsized_delete_called;
-    std::free(p);
-}
-
-void operator delete(void* p, const std::nothrow_t&) throw()
-{
-    ++unsized_delete_nothrow_called;
-    std::free(p);
-}
-
-void operator delete(void* p, std::size_t) throw()
-{
-    ++sized_delete_called;
-    std::free(p);
-}
-
-void operator delete(void* p, std::size_t, const std::nothrow_t&) throw()
-{
-    ++sized_delete_nothrow_called;
-    std::free(p);
-}
-
-int new_handler_called = 0;
-
-void new_handler()
-{
-    ++new_handler_called;
-    std::set_new_handler(0);
-}
-
-bool A_constructed = false;
-
-struct A
-{
-    A() {A_constructed = true;}
-    ~A() {A_constructed = false;}
-};
-
-struct BadA : public A {
-    BadA() { throw std::bad_alloc(); }
-};
-
-int main()
-{
-    std::set_new_handler(new_handler);
-    try
-    {
-        void*volatile vp = operator new (std::numeric_limits<std::size_t>::max(), std::nothrow);
-        assert(new_handler_called == 1);
-        assert(vp == 0);
-    }
-    catch (...)
-    {
-        assert(false);
-    }
-    try
-    {
-        A* ap = new(std::nothrow) BadA;
-        assert(false);
-    }
-    catch (...)
-    {
-        assert(!A_constructed);
-#if _LIBCPP_STD_VER >= 14
-        // FIXME: Do we need a version of [Expr.Delete]#10 for nothrow
-        // deallocation functions (selecting sized ones whenever available)?
-        // It is not required by the standard. If it were, the following would
-        // be the expected behaviour (instead of the current one):
-        //   assert(!unsized_delete_nothrow_called);
-        //   assert(sized_delete_nothrow_called == 1);
-        assert(unsized_delete_nothrow_called == 1);
-        assert(!sized_delete_nothrow_called);
-#else // if _LIBCPP_STD_VER < 14
-        assert(unsized_delete_nothrow_called == 1);
-        assert(!sized_delete_nothrow_called);
-#endif
-        assert(!unsized_delete_called);
-        assert(!sized_delete_called);
-    }
-}





More information about the cfe-commits mailing list