diff options
Diffstat (limited to 'compiler-rt/test/asan/TestCases/use-after-scope-loop-removed.cc')
| -rw-r--r-- | compiler-rt/test/asan/TestCases/use-after-scope-loop-removed.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-loop-removed.cc b/compiler-rt/test/asan/TestCases/use-after-scope-loop-removed.cc new file mode 100644 index 00000000000..a9ea4505199 --- /dev/null +++ b/compiler-rt/test/asan/TestCases/use-after-scope-loop-removed.cc @@ -0,0 +1,19 @@ +// RUN: %clangxx_asan -O1 -mllvm -asan-use-after-scope=1 %s -o %t && \ +// RUN: not %run %t 2>&1 | FileCheck %s +// +// FIXME: Compiler removes for-loop but keeps x variable. For unknown reason +// @llvm.lifetime.* are not emitted for x. +// XFAIL: * + +#include <stdlib.h> + +int *p; + +int main() { + for (int i = 0; i < 3; i++) { + int x; + p = &x; + } + return **p; // BOOM + // CHECK: ERROR: AddressSanitizer: stack-use-after-scope +} |

