xref: /llvm-project/compiler-rt/test/asan/TestCases/global-overflow.cpp (revision 961bc37d449819e0c959f385f7927cd8b8dc9037)
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 // Issue #108194: Incomplete .debug_line at -O1 and above.
7 // XFAIL: target={{.*sparc.*}}
8 
9 #include <string.h>
10 int main(int argc, char **argv) {
11   static char XXX[10];
12   static char YYY[10];
13   static char ZZZ[10];
14   memset(XXX, 0, 10);
15   memset(YYY, 0, 10);
16   memset(ZZZ, 0, 10);
17   int res = YYY[argc * 10];  // BOOOM
18   // CHECK: {{READ of size 1 at 0x.* thread T0}}
19   // CHECK: {{    #0 0x.* in main .*global-overflow.cpp:}}[[@LINE-2]]
20   // CHECK: {{0x.* is located 0 bytes after global variable}}
21   // CHECK:   {{.*YYY.* of size 10}}
22   res += XXX[argc] + ZZZ[argc];
23   return res;
24 }
25