xref: /llvm-project/compiler-rt/test/asan/TestCases/use-after-scope-loop.cpp (revision cd269daf25016f7115424a51ab5e7977a80e072d)
1 // RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s
2 
3 int *p[3];
4 
main()5 int main() {
6   for (int i = 0; i < 3; i++) {
7     int x;
8     p[i] = &x;
9   }
10   return **p;  // BOOM
11   // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
12   // CHECK: #0 0x{{.*}} in main {{.*}}.cpp:[[@LINE-2]]
13 }
14