xref: /aosp_15_r20/external/compiler-rt/test/asan/TestCases/partial_right.cc (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
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 
6*7c3d14c8STreehugger Robot #include <stdlib.h>
main(int argc,char ** argv)7*7c3d14c8STreehugger Robot int main(int argc, char **argv) {
8*7c3d14c8STreehugger Robot   volatile int *x = (int*)malloc(2*sizeof(int) + 2);
9*7c3d14c8STreehugger Robot   int res = x[2];  // BOOOM
10*7c3d14c8STreehugger Robot   // CHECK: {{READ of size 4 at 0x.* thread T0}}
11*7c3d14c8STreehugger Robot   // CHECK: [[ADDR:0x[01-9a-fa-f]+]] is located 0 bytes to the right of {{.*}}-byte region [{{.*}},{{.*}}[[ADDR]])
12*7c3d14c8STreehugger Robot   return res;
13*7c3d14c8STreehugger Robot }
14