xref: /aosp_15_r20/external/compiler-rt/test/asan/TestCases/use-after-scope-nobug.cc (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O1 -fsanitize-address-use-after-scope %s -o %t && %run %t
2*7c3d14c8STreehugger Robot 
3*7c3d14c8STreehugger Robot #include <stdio.h>
4*7c3d14c8STreehugger Robot #include <stdlib.h>
5*7c3d14c8STreehugger Robot 
6*7c3d14c8STreehugger Robot int *p[3];
7*7c3d14c8STreehugger Robot 
main()8*7c3d14c8STreehugger Robot int main() {
9*7c3d14c8STreehugger Robot   // Variable goes in and out of scope.
10*7c3d14c8STreehugger Robot   for (int i = 0; i < 3; i++) {
11*7c3d14c8STreehugger Robot     int x;
12*7c3d14c8STreehugger Robot     p[i] = &x;
13*7c3d14c8STreehugger Robot   }
14*7c3d14c8STreehugger Robot   printf("PASSED\n");
15*7c3d14c8STreehugger Robot   return 0;
16*7c3d14c8STreehugger Robot }
17