12d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
22d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
32d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
42d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
52d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines
62d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines#include <string.h>
72d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hinesint main(int argc, char **argv) {
82d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  char x[10];
92d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  memset(x, 0, 10);
102d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  int res = x[argc * 10];  // BOOOM
112d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  // CHECK: {{READ of size 1 at 0x.* thread T0}}
122d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  // CHECK: {{    #0 0x.* in main .*stack-buffer-overflow.cc:}}[[@LINE-2]]
132d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  // CHECK: {{Address 0x.* is located in stack of thread T0 at offset}}
142d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  // CHECK-NEXT: in{{.*}}main{{.*}}stack-buffer-overflow.cc
152d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines  return res;
162d1fdb26e458c4ddc04155c1d421bced3ba90cd0Stephen Hines}