xref: /llvm-project/compiler-rt/test/hwasan/TestCases/use-after-scope-nobug.cpp (revision 6cc9244baa63fcb7c6f35f46dab9fa17a421a6ce)
1 // This is the ASAN test of the same name ported to HWAsan.
2 
3 // RUN: %clangxx_hwasan -O1 %s -o %t && %run %t
4 
5 // REQUIRES: aarch64-target-arch || riscv64-target-arch
6 
7 #include <stdio.h>
8 #include <stdlib.h>
9 
10 int *p[3];
11 
main()12 int main() {
13   // Variable goes in and out of scope.
14   for (int i = 0; i < 3; i++) {
15     int x;
16     p[i] = &x;
17   }
18   printf("PASSED\n");
19   return 0;
20 }
21