1 | // RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s |
2 | // RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s |
3 | // RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s |
4 | // RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s |
5 | |
6 | #include <string.h> |
7 | int main(int argc, char **argv) { |
8 | static char XXX[10]; |
9 | static char YYY[10]; |
10 | static char ZZZ[10]; |
11 | memset(s: XXX, c: 0, n: 10); |
12 | memset(s: YYY, c: 0, n: 10); |
13 | memset(s: ZZZ, c: 0, n: 10); |
14 | int res = YYY[argc * 10]; // BOOOM |
15 | // CHECK: {{READ of size 1 at 0x.* thread T0}} |
16 | // CHECK: {{ #0 0x.* in main .*global-overflow.cpp:}}[[@LINE-2]] |
17 | // CHECK: {{0x.* is located 0 bytes after global variable}} |
18 | // CHECK: {{.*YYY.* of size 10}} |
19 | res += XXX[argc] + ZZZ[argc]; |
20 | return res; |
21 | } |
22 | |