• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_cl_asan -O0 %s -Fe%t
2 // RUN: not %run %t 2>&1 | FileCheck %s
3 
4 #include <stdio.h>
5 
main()6 int main() {
7   int subscript = -1;
8   char buffer[42];
9   buffer[subscript] = 42;
10 // CHECK: AddressSanitizer: stack-buffer-underflow on address [[ADDR:0x[0-9a-f]+]]
11 // CHECK: WRITE of size 1 at [[ADDR]] thread T0
12 // CHECK-NEXT: {{#0 .* main .*stack_array_left_oob.cc}}:[[@LINE-3]]
13 // CHECK: Address [[ADDR]] is located in stack of thread T0 at offset [[OFFSET:.*]] in frame
14 // CHECK-NEXT: {{#0 .* main .*stack_array_left_oob.cc}}
15 // CHECK: 'buffer' <== Memory access at offset [[OFFSET]] underflows this variable
16 }
17