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