aboutsummaryrefslogtreecommitdiff
path: root/test/asan/TestCases/use-after-scope-loop-bug.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/asan/TestCases/use-after-scope-loop-bug.cc')
-rw-r--r--test/asan/TestCases/use-after-scope-loop-bug.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/asan/TestCases/use-after-scope-loop-bug.cc b/test/asan/TestCases/use-after-scope-loop-bug.cc
new file mode 100644
index 000000000000..6ad9bf3260cc
--- /dev/null
+++ b/test/asan/TestCases/use-after-scope-loop-bug.cc
@@ -0,0 +1,16 @@
+// RUN: %clangxx_asan -O1 -fsanitize-address-use-after-scope %s -o %t && \
+// RUN: not %run %t 2>&1 | FileCheck %s
+//
+// FIXME: @llvm.lifetime.* are not emitted for x.
+// XFAIL: *
+
+int *p;
+
+int main() {
+ // Variable goes in and out of scope.
+ for (int i = 0; i < 3; ++i) {
+ int x[3] = {i, i, i};
+ p = x + i;
+ }
+ return *p; // BOOM
+}