From: Paul Floyd Date: Mon, 9 Nov 2020 08:37:17 +0000 (+0100) Subject: Add testcase for C++14 sized delete X-Git-Tag: VALGRIND_3_17_0~129 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6faec425f13025084076e6fd2e1399a1834a3782;p=thirdparty%2Fvalgrind.git Add testcase for C++14 sized delete --- diff --git a/.gitignore b/.gitignore index 18067259c1..47e53a9542 100644 --- a/.gitignore +++ b/.gitignore @@ -901,6 +901,7 @@ /memcheck/tests/sigkill /memcheck/tests/signal2 /memcheck/tests/sigprocmask +/memcheck/tests/sized_delete /memcheck/tests/stack_changes /memcheck/tests/stack_switch /memcheck/tests/static_malloc diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 84b2a81cea..28f26bbebe 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -69,7 +69,8 @@ dist_noinst_SCRIPTS = \ filter_strchr \ filter_varinfo3 \ filter_memcheck \ - filter_overlaperror + filter_overlaperror \ + filter_sized_delete noinst_HEADERS = leak.h @@ -267,6 +268,7 @@ EXTRA_DIST = \ sigkill.stderr.exp-glibc-2.28 sigkill.vgtest \ signal2.stderr.exp signal2.stdout.exp signal2.vgtest \ sigprocmask.stderr.exp sigprocmask.stderr.exp2 sigprocmask.vgtest \ + sized_delete.stderr.exp sized_delete.stderr.exp-x86 sized_delete.vgtest \ static_malloc.stderr.exp static_malloc.vgtest \ stpncpy.vgtest stpncpy.stderr.exp stpncpy.stdout.exp \ strchr.stderr.exp strchr.stderr.exp2 strchr.stderr.exp3 strchr.vgtest \ @@ -397,6 +399,7 @@ check_PROGRAMS = \ sendmsg \ sh-mem sh-mem-random \ sigaltstack signal2 sigprocmask static_malloc sigkill \ + sized_delete \ strchr \ str_tester \ supp_unknown supp1 supp2 suppfree \ @@ -549,6 +552,9 @@ sendmsg_CFLAGS += -D_XOPEN_SOURCE=600 sendmsg_LDADD = -lsocket -lnsl endif +sized_delete_SOURCES = sized_delete.cpp +sized_delete_CXXFLAGS = $(AM_CXXFLAGS) -fsized-deallocation + str_tester_CFLAGS = $(AM_CFLAGS) -Wno-shadow \ @FLAG_W_NO_MEMSET_TRANSPOSED_ARGS@ diff --git a/memcheck/tests/filter_sized_delete b/memcheck/tests/filter_sized_delete new file mode 100755 index 0000000000..54dea76b5d --- /dev/null +++ b/memcheck/tests/filter_sized_delete @@ -0,0 +1,4 @@ +#! /bin/sh + +./filter_stderr "$@" | +grep -v free | grep -v malloc diff --git a/memcheck/tests/sized_delete b/memcheck/tests/sized_delete new file mode 100755 index 0000000000..a9f716d73e Binary files /dev/null and b/memcheck/tests/sized_delete differ diff --git a/memcheck/tests/sized_delete.cpp b/memcheck/tests/sized_delete.cpp new file mode 100644 index 0000000000..24379d1a7e --- /dev/null +++ b/memcheck/tests/sized_delete.cpp @@ -0,0 +1,12 @@ +class MyClass { + int i; + +}; + +int main() { + MyClass* myClass = new MyClass(); + delete myClass; + MyClass* myClass5 = new MyClass[5]; + operator delete[](myClass5, 5U*sizeof(MyClass)); + //delete [] myClass5; +} diff --git a/memcheck/tests/sized_delete.stderr.exp b/memcheck/tests/sized_delete.stderr.exp new file mode 100644 index 0000000000..91bd71c388 --- /dev/null +++ b/memcheck/tests/sized_delete.stderr.exp @@ -0,0 +1,4 @@ +_Znwm(4) = 0x........ +_ZdlPvm(0x........) +_Znam(20) = 0x........ +_ZdaPvm(0x........) diff --git a/memcheck/tests/sized_delete.stderr.exp-x86 b/memcheck/tests/sized_delete.stderr.exp-x86 new file mode 100644 index 0000000000..1f6e9f9155 --- /dev/null +++ b/memcheck/tests/sized_delete.stderr.exp-x86 @@ -0,0 +1,4 @@ +_Znwj(4) = 0x........ +_ZdlPvj(0x........) +_Znaj(20) = 0x........ +_ZdaPvj(0x........) diff --git a/memcheck/tests/sized_delete.vgtest b/memcheck/tests/sized_delete.vgtest new file mode 100644 index 0000000000..9f483e01c4 --- /dev/null +++ b/memcheck/tests/sized_delete.vgtest @@ -0,0 +1,4 @@ +prog: sized_delete +prereq: test -e sized_delete +vgopts: -q "--trace-malloc=yes" --show-mismatched-frees=yes +stderr_filter: filter_sized_delete