blob: cd71a5046cd48e6c272ff69a55c255bb7e194497 [file] [log] [blame]
Vitaly Buka0ba360b2016-07-14 21:18:06 +00001// RUN: %clangxx_asan -O1 -fsanitize-address-use-after-scope %s -o %t && \
Evgeniy Stepanov4c0f6af2016-04-22 00:10:23 +00002// 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
10int *p;
11
12int 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}