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