From d8ce87f850ad4b04770b3af7b18ae2dbefd5f012 Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Mon, 18 Apr 2016 21:36:34 +0000 Subject: [PATCH] Additional test for use-after-scope Summary: Test that asan detects access to the dead variable captured by lambda. Reviewers: aizatsky, kcc Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D19238 llvm-svn: 266676 --- compiler-rt/test/asan/TestCases/use-after-scope-capture.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 compiler-rt/test/asan/TestCases/use-after-scope-capture.cc diff --git a/compiler-rt/test/asan/TestCases/use-after-scope-capture.cc b/compiler-rt/test/asan/TestCases/use-after-scope-capture.cc new file mode 100644 index 0000000..28c99b4 --- /dev/null +++ b/compiler-rt/test/asan/TestCases/use-after-scope-capture.cc @@ -0,0 +1,14 @@ +// RUN: %clangxx_asan -O0 -fsanitize=use-after-scope %s -o %t && %run %t +// XFAIL: * + +int main() { + std::function f; + { + int x = 0; + f = [&x]() { + return x; + } + } + return f(); // BOOM + // CHECK: ERROR: AddressSanitizer: stack-use-after-scope +} -- 2.7.4