1*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s 2*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s 3*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s 4*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s 5*7c3d14c8STreehugger Robot // RUN: %env_asan_opts=print_stats=1 not %run %t 2>&1 | FileCheck %s 6*7c3d14c8STreehugger Robot 7*7c3d14c8STreehugger Robot // FIXME: Fix this test under GCC. 8*7c3d14c8STreehugger Robot // REQUIRES: Clang 9*7c3d14c8STreehugger Robot 10*7c3d14c8STreehugger Robot #include <stdlib.h> 11*7c3d14c8STreehugger Robot #include <string.h> main(int argc,char ** argv)12*7c3d14c8STreehugger Robotint main(int argc, char **argv) { 13*7c3d14c8STreehugger Robot char *x = (char*)malloc(10 * sizeof(char)); 14*7c3d14c8STreehugger Robot memset(x, 0, 10); 15*7c3d14c8STreehugger Robot int res = x[argc * 10]; // BOOOM 16*7c3d14c8STreehugger Robot // CHECK: {{READ of size 1 at 0x.* thread T0}} 17*7c3d14c8STreehugger Robot // CHECK: {{ #0 0x.* in main .*heap-overflow.cc:}}[[@LINE-2]] 18*7c3d14c8STreehugger Robot // CHECK: {{0x.* is located 0 bytes to the right of 10-byte region}} 19*7c3d14c8STreehugger Robot // CHECK: {{allocated by thread T0 here:}} 20*7c3d14c8STreehugger Robot 21*7c3d14c8STreehugger Robot // CHECK: {{ #0 0x.* in .*malloc}} 22*7c3d14c8STreehugger Robot free(x); 23*7c3d14c8STreehugger Robot return res; 24*7c3d14c8STreehugger Robot } 25