aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2016-07-21 20:38:57 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2016-07-21 20:38:57 +0100
commit509b778f6cb7c99159ecdf3e4caa28468b2f46e5 (patch)
treef1d4d2f2ce4464822f9185d06dcc7ef2c7fbafdf
parente93a101f83b67b47f2247505ff6fa9f39aa47442 (diff)
downloadgcc-509b778f6cb7c99159ecdf3e4caa28468b2f46e5.zip
gcc-509b778f6cb7c99159ecdf3e4caa28468b2f46e5.tar.gz
gcc-509b778f6cb7c99159ecdf3e4caa28468b2f46e5.tar.bz2
Define missing delete operators in libstdc++ testsuite
* testsuite/23_containers/vector/zero_sized_allocations.cc: Define sized deallocation function. * testsuite/util/testsuite_new_operators.h: (operator delete(void*, const std::nothrow_t&)): Define nothrow deallocation function. From-SVN: r238610
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/testsuite/23_containers/vector/zero_sized_allocations.cc12
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_new_operators.h7
3 files changed, 23 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 7ad9478..9a0a71b 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,5 +1,11 @@
2016-07-21 Jonathan Wakely <jwakely@redhat.com>
+ * testsuite/23_containers/vector/zero_sized_allocations.cc:
+ Define sized deallocation function.
+ * testsuite/util/testsuite_new_operators.h:
+ (operator delete(void*, const std::nothrow_t&)): Define nothrow
+ deallocation function.
+
* testsuite/21_strings/basic_string/modifiers/append/char/1.cc: Fix
reads past the end of strings.
* testsuite/21_strings/basic_string/operations/compare/char/1.cc:
diff --git a/libstdc++-v3/testsuite/23_containers/vector/zero_sized_allocations.cc b/libstdc++-v3/testsuite/23_containers/vector/zero_sized_allocations.cc
index 236b82f..74fa95c 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/zero_sized_allocations.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/zero_sized_allocations.cc
@@ -22,7 +22,7 @@
unsigned int zero_sized_news = 0;
-void *operator new(size_t size) throw (std::bad_alloc)
+void *operator new(std::size_t size) throw (std::bad_alloc)
{
/* malloc(0) is unpredictable; avoid it. */
if (size == 0)
@@ -45,6 +45,14 @@ void operator delete(void *ptr) throw()
std::free(ptr);
}
+#if __cpp_sized_deallocation
+void operator delete(void *ptr, std::size_t) throw()
+{
+ if (ptr != 0)
+ std::free(ptr);
+}
+#endif
+
// http://gcc.gnu.org/ml/libstdc++/2007-09/msg00006.html
void test01()
{
@@ -57,7 +65,7 @@ void test01()
VERIFY( zero_sized_news == 0 );
v->resize(10);
- delete(v);
+ delete v;
VERIFY( zero_sized_news == 0 );
}
diff --git a/libstdc++-v3/testsuite/util/testsuite_new_operators.h b/libstdc++-v3/testsuite/util/testsuite_new_operators.h
index 70603fa..6713fb8 100644
--- a/libstdc++-v3/testsuite/util/testsuite_new_operators.h
+++ b/libstdc++-v3/testsuite/util/testsuite_new_operators.h
@@ -64,6 +64,13 @@ void operator delete(void* p) throw()
std::free(p);
}
+void operator delete(void* p, const std::nothrow_t&) throw()
+{
+ if (p)
+ std::free(p);
+}
+
+
#endif // _GLIBCXX_TESTSUITE_NEW_OPERATORS_H