[compiler-rt] r266676 - Additional test for use-after-scope

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 18 14:36:34 PDT 2016


Author: kcc
Date: Mon Apr 18 16:36:34 2016
New Revision: 266676

URL: http://llvm.org/viewvc/llvm-project?rev=266676&view=rev
Log:
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

Added:
    compiler-rt/trunk/test/asan/TestCases/use-after-scope-capture.cc

Added: compiler-rt/trunk/test/asan/TestCases/use-after-scope-capture.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/use-after-scope-capture.cc?rev=266676&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/use-after-scope-capture.cc (added)
+++ compiler-rt/trunk/test/asan/TestCases/use-after-scope-capture.cc Mon Apr 18 16:36:34 2016
@@ -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
+}




More information about the llvm-commits mailing list