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
10int *p[3];
11
12int 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(format: "PASSED\n");
19 return 0;
20}
21

source code of compiler-rt/test/hwasan/TestCases/use-after-scope-nobug.cpp