]> git.proxmox.com Git - rustc.git/blob - src/llvm/projects/compiler-rt/lib/asan/lit_tests/global-overflow.cc
Imported Upstream version 0.6
[rustc.git] / src / llvm / projects / compiler-rt / lib / asan / lit_tests / global-overflow.cc
1 // RUN: %clangxx_asan -m64 -O0 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
2 // RUN: %clangxx_asan -m64 -O1 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
3 // RUN: %clangxx_asan -m64 -O2 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
4 // RUN: %clangxx_asan -m64 -O3 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
5 // RUN: %clangxx_asan -m32 -O0 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
6 // RUN: %clangxx_asan -m32 -O1 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
7 // RUN: %clangxx_asan -m32 -O2 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
8 // RUN: %clangxx_asan -m32 -O3 %s -o %t && %t 2>&1 | %symbolize | FileCheck %s
9
10 #include <string.h>
11 int main(int argc, char **argv) {
12 static char XXX[10];
13 static char YYY[10];
14 static char ZZZ[10];
15 memset(XXX, 0, 10);
16 memset(YYY, 0, 10);
17 memset(ZZZ, 0, 10);
18 int res = YYY[argc * 10]; // BOOOM
19 // CHECK: {{READ of size 1 at 0x.* thread T0}}
20 // CHECK: {{ #0 0x.* in main .*global-overflow.cc:18}}
21 // CHECK: {{0x.* is located 0 bytes to the right of global variable}}
22 // CHECK: {{.*YYY.* of size 10}}
23 res += XXX[argc] + ZZZ[argc];
24 return res;
25 }