1 // RUN: %clangxx_asan -O1 -fsanitize-address-use-after-scope %s -o %t && \
2 // RUN:     not %run %t 2>&1 | FileCheck %s
3 //
4 // FIXME: Compiler removes for-loop but keeps x variable. For unknown reason
5 // @llvm.lifetime.* are not emitted for x.
6 // XFAIL: *
7 
8 #include <stdlib.h>
9 
10 int *p;
11 
main()12 int main() {
13   for (int i = 0; i < 3; i++) {
14     int x;
15     p = &x;
16   }
17   return **p;  // BOOM
18   // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
19 }
20