Mercurial > hg > CbC > CbC_llvm
annotate projects/compiler-rt/test/scudo/sized-delete.cpp @ 214:0cf2d4ade63d
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 13 Jul 2021 09:53:52 +0900 |
parents | f476a9ba4795 |
children |
rev | line source |
---|---|
131
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
1 // RUN: %clangxx_scudo -fsized-deallocation %s -o %t |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
2 // RUN: %env_scudo_opts=DeleteSizeMismatch=1 %run %t gooddel 2>&1 |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
3 // RUN: %env_scudo_opts=DeleteSizeMismatch=1 not %run %t baddel 2>&1 | FileCheck %s |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
4 // RUN: %env_scudo_opts=DeleteSizeMismatch=0 %run %t baddel 2>&1 |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
5 // RUN: %env_scudo_opts=DeleteSizeMismatch=1 %run %t gooddelarr 2>&1 |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
6 // RUN: %env_scudo_opts=DeleteSizeMismatch=1 not %run %t baddelarr 2>&1 | FileCheck %s |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
7 // RUN: %env_scudo_opts=DeleteSizeMismatch=0 %run %t baddelarr 2>&1 |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
8 |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
9 // Ensures that the sized delete operator errors out when the appropriate |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
10 // option is passed and the sizes do not match between allocation and |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
11 // deallocation functions. |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
12 |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
13 #include <assert.h> |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
14 #include <stdlib.h> |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
15 #include <string.h> |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
16 |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
17 #include <new> |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
18 |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
19 int main(int argc, char **argv) |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
20 { |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
21 assert(argc == 2); |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
22 if (!strcmp(argv[1], "gooddel")) { |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
23 long long *p = new long long; |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
24 operator delete(p, sizeof(long long)); |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
25 } |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
26 if (!strcmp(argv[1], "baddel")) { |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
27 long long *p = new long long; |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
28 operator delete(p, 2); |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
29 } |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
30 if (!strcmp(argv[1], "gooddelarr")) { |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
31 char *p = new char[64]; |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
32 operator delete[](p, 64); |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
33 } |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
34 if (!strcmp(argv[1], "baddelarr")) { |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
35 char *p = new char[63]; |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
36 operator delete[](p, 64); |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
37 } |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
38 return 0; |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
39 } |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
40 |
f476a9ba4795
http://llvm.org/svn/llvm-project/compiler-rt/trunk compiler-rt
mir3636
parents:
diff
changeset
|
41 // CHECK: ERROR: invalid sized delete on chunk at address |