blob: a9ea45051997208f79fe1894f3afc6816c3aadd4 [file] [log] [blame]
Evgeniy Stepanov4c0f6af2016-04-22 00:10:23 +00001// RUN: %clangxx_asan -O1 -mllvm -asan-use-after-scope=1 %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
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}