]> git.proxmox.com Git - rustc.git/blame - src/compiler-rt/test/asan/TestCases/use-after-scope-loop-removed.cc
New upstream version 1.18.0+dfsg1
[rustc.git] / src / compiler-rt / test / asan / TestCases / use-after-scope-loop-removed.cc
CommitLineData
5bcae85e
SL
1// RUN: %clangxx_asan -O1 -fsanitize-address-use-after-scope %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}