summaryrefslogtreecommitdiffstats
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
commitd8ce87f850ad4b04770b3af7b18ae2dbefd5f012 (patch)
tree74a13369ed853fb3a514e3d1fd850eeaf56862aa
parente6643daa1850722e7ac7660e8c6c4932dc6eaa33 (diff)
downloadbcm5719-llvm-d8ce87f850ad4b04770b3af7b18ae2dbefd5f012.tar.gz
bcm5719-llvm-d8ce87f850ad4b04770b3af7b18ae2dbefd5f012.zip
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
-rw-r--r--compiler-rt/test/asan/TestCases/use-after-scope-capture.cc14
1 files changed, 14 insertions, 0 deletions
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 00000000000..28c99b446bf
--- /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<int()> f;
+ {
+ int x = 0;
+ f = [&x]() {
+ return x;
+ }
+ }
+ return f(); // BOOM
+ // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
+}
OpenPOWER on IntegriCloud