[compiler-rt] r289090 - [asan] Add test which detects bugs undetectable before r288563

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 8 11:13:13 PST 2016


Author: vitalybuka
Date: Thu Dec  8 13:13:13 2016
New Revision: 289090

URL: http://llvm.org/viewvc/llvm-project?rev=289090&view=rev
Log:
[asan] Add test which detects bugs undetectable before r288563

Reviewers: kcc, eugenis

Subscribers: llvm-commits, kubabrecka

Differential Revision: https://reviews.llvm.org/D27583

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

Added: compiler-rt/trunk/test/asan/TestCases/use-after-scope-temp2.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/use-after-scope-temp2.cc?rev=289090&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/use-after-scope-temp2.cc (added)
+++ compiler-rt/trunk/test/asan/TestCases/use-after-scope-temp2.cc Thu Dec  8 13:13:13 2016
@@ -0,0 +1,20 @@
+// RUN: %clangxx_asan %stdcxx11 -O1 -fsanitize-address-use-after-scope %s -o %t && \
+// RUN:     not %run %t 2>&1 | FileCheck %s
+
+
+struct IntHolder {
+  const IntHolder& Self() const {
+    return *this;
+  }
+  int val = 3;
+};
+
+const IntHolder *saved;
+
+int main(int argc, char *argv[]) {
+  saved = &IntHolder().Self();
+  int x = saved->val;  // BOOM
+  // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
+  // CHECK:  #0 0x{{.*}} in main {{.*}}use-after-scope-temp2.cc:[[@LINE-2]]
+  return x;
+}




More information about the llvm-commits mailing list