diff options
Diffstat (limited to 'test/asan/TestCases/partial_right.cc')
-rw-r--r-- | test/asan/TestCases/partial_right.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/asan/TestCases/partial_right.cc b/test/asan/TestCases/partial_right.cc new file mode 100644 index 000000000000..b60c1a597635 --- /dev/null +++ b/test/asan/TestCases/partial_right.cc @@ -0,0 +1,13 @@ +// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s +// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s + +#include <stdlib.h> +int main(int argc, char **argv) { + volatile int *x = (int*)malloc(2*sizeof(int) + 2); + int res = x[2]; // BOOOM + // CHECK: {{READ of size 4 at 0x.* thread T0}} + // CHECK: [[ADDR:0x[01-9a-fa-f]+]] is located 0 bytes to the right of {{.*}}-byte region [{{.*}},{{.*}}[[ADDR]]) + return res; +} |