1 // RUN: %clangxx_asan -O1 -fsanitize-address-use-after-scope %s -o %t && \
2 // RUN:     not %run %t 2>&1 | FileCheck %s
3 
4 // -fsanitize-address-use-after-scope is now on by default:
5 // RUN: %clangxx_asan -O1 %s -o %t && \
6 // RUN:     not %run %t 2>&1 | FileCheck %s
7 
8 volatile int *p = 0;
9 
main()10 int main() {
11   {
12     int x = 0;
13     p = &x;
14   }
15   *p = 5;  // BOOM
16   // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
17   // CHECK:  #0 0x{{.*}} in main {{.*}}use-after-scope.cpp:[[@LINE-2]]
18   // CHECK: Address 0x{{.*}} is located in stack of thread T{{.*}} at offset [[OFFSET:[^ ]+]] in frame
19   // {{\[}}[[OFFSET]], {{[0-9]+}}) 'x'
20   return 0;
21 }
22