xref: /aosp_15_r20/external/compiler-rt/test/asan/TestCases/poison_partial.cc (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O0 %s -o %t
2*7c3d14c8STreehugger Robot // RUN: not %run %t      2>&1 | FileCheck %s
3*7c3d14c8STreehugger Robot // RUN: not %run %t heap 2>&1 | FileCheck %s
4*7c3d14c8STreehugger Robot // RUN: %env_asan_opts=poison_partial=0 %run %t
5*7c3d14c8STreehugger Robot // RUN: %env_asan_opts=poison_partial=0 %run %t heap
6*7c3d14c8STreehugger Robot #include <string.h>
7*7c3d14c8STreehugger Robot char g[21];
8*7c3d14c8STreehugger Robot char *x;
9*7c3d14c8STreehugger Robot 
main(int argc,char ** argv)10*7c3d14c8STreehugger Robot int main(int argc, char **argv) {
11*7c3d14c8STreehugger Robot   if (argc >= 2)
12*7c3d14c8STreehugger Robot     x = new char[21];
13*7c3d14c8STreehugger Robot   else
14*7c3d14c8STreehugger Robot     x = &g[0];
15*7c3d14c8STreehugger Robot   memset(x, 0, 21);
16*7c3d14c8STreehugger Robot   int *y = (int*)x;
17*7c3d14c8STreehugger Robot   return y[5];
18*7c3d14c8STreehugger Robot }
19*7c3d14c8STreehugger Robot // CHECK: 0 bytes to the right
20