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