stack-buffer-overflow.cc revision 2d1fdb26e458c4ddc04155c1d421bced3ba90cd0
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>
7int main(int argc, char **argv) {
8  char x[10];
9  memset(x, 0, 10);
10  int res = x[argc * 10];  // BOOOM
11  // CHECK: {{READ of size 1 at 0x.* thread T0}}
12  // CHECK: {{    #0 0x.* in main .*stack-buffer-overflow.cc:}}[[@LINE-2]]
13  // CHECK: {{Address 0x.* is located in stack of thread T0 at offset}}
14  // CHECK-NEXT: in{{.*}}main{{.*}}stack-buffer-overflow.cc
15  return res;
16}
17