From: Julian Seward Date: Sat, 18 May 2002 19:54:36 +0000 (+0000) Subject: Add test from Lionel Ulmer showing incorrect behaviour of overloaded X-Git-Tag: svn/VALGRIND_1_0_3~172 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=312f5a2c51e043469498e2e835db97a321a29e61;p=thirdparty%2Fvalgrind.git Add test from Lionel Ulmer showing incorrect behaviour of overloaded new. Not fixed yet. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@294 --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 9db71ca411..93a79cfea5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -28,4 +28,4 @@ EXTRA_DIST = \ bt_everything.c bt_literal.c \ pth_threadpool.c pth_specific.c pth_mutexspeed.c malloc3.c \ pth_once.c weirdioctl.c pth_signal1.c pth_signal2.c \ - discard.c pth_semaphore1.c + discard.c pth_semaphore1.c new_override.cpp diff --git a/tests/new_override.cpp b/tests/new_override.cpp new file mode 100644 index 0000000000..8aafd043c3 --- /dev/null +++ b/tests/new_override.cpp @@ -0,0 +1,30 @@ +#include +#include + +class Test { +public: + int a, b, c, d; +}; + +void *operator new(size_t size) +{ + void *ret = malloc(size); + printf("Here.\n"); + for (unsigned int i = 0; i < size; i++) ((char *) ret)[i] = 0xFF; + return ret; +} + +int main(int argc, char *argv[]) { + Test *toto; + int i; + int j = 0; + + toto = new Test[2]; + + for (i = 0; i < 2; i++) { + if (toto[i].a) { + j++; + } + printf("%d : %08x %08x %08x %08x\n", i, toto[i].a, toto[i].b, toto[i].c, toto[i].d); + } +}