]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add test from Lionel Ulmer showing incorrect behaviour of overloaded
authorJulian Seward <jseward@acm.org>
Sat, 18 May 2002 19:54:36 +0000 (19:54 +0000)
committerJulian Seward <jseward@acm.org>
Sat, 18 May 2002 19:54:36 +0000 (19:54 +0000)
new.  Not fixed yet.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@294

tests/Makefile.am
tests/new_override.cpp [new file with mode: 0644]

index 9db71ca4113190ff5254f717b48b39657f589f42..93a79cfea5e4da24177429641293098cd439349a 100644 (file)
@@ -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 (file)
index 0000000..8aafd04
--- /dev/null
@@ -0,0 +1,30 @@
+#include <stdlib.h>
+#include <stdio.h>
+
+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);
+  }
+}