summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2016-04-18 21:36:34 +0000
committerKostya Serebryany <kcc@google.com>2016-04-18 21:36:34 +0000
commit67c4cad56d662b70fa341c55871cfc176198b8d7 (patch)
treeec5b98fd71aea9700568cfc533fedff56e75abc5 /test
parent82cd9449dfb3fe89012fd2294133dc93e6aa5cb5 (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@266676 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/asan/TestCases/use-after-scope-capture.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/asan/TestCases/use-after-scope-capture.cc b/test/asan/TestCases/use-after-scope-capture.cc
new file mode 100644
index 000000000..28c99b446
--- /dev/null
+++ b/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<int()> f;
+ {
+ int x = 0;
+ f = [&x]() {
+ return x;
+ }
+ }
+ return f(); // BOOM
+ // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
+}