Evgeniy Stepanov | 4c0f6af | 2016-04-22 00:10:23 +0000 | [diff] [blame] | 1 | // 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 | |||||
10 | int *p; | ||||
11 | |||||
12 | int 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 | } |