[compiler-rt] r312039 - [asan] Add use-after-scope test which fails because of bug in clang
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 29 14:23:44 PDT 2017
Author: vitalybuka
Date: Tue Aug 29 14:23:44 2017
New Revision: 312039
URL: http://llvm.org/viewvc/llvm-project?rev=312039&view=rev
Log:
[asan] Add use-after-scope test which fails because of bug in clang
Reviewers: kcc, eugenis
Subscribers: llvm-commits, kubamracek
Differential Revision: https://reviews.llvm.org/D37242
Added:
compiler-rt/trunk/test/asan/TestCases/use-after-scope-conversion.cc
Added: compiler-rt/trunk/test/asan/TestCases/use-after-scope-conversion.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/use-after-scope-conversion.cc?rev=312039&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/use-after-scope-conversion.cc (added)
+++ compiler-rt/trunk/test/asan/TestCases/use-after-scope-conversion.cc Tue Aug 29 14:23:44 2017
@@ -0,0 +1,50 @@
+// RUN: %clangxx_asan -O0 -fsanitize-address-use-after-scope %s -o %t
+
+// RUN: not %run %t 'A' 2>&1 | FileCheck %s
+// RUN: not %run %t 'B' 2>&1 | FileCheck %s
+
+// Missing lifetime markers in test_a
+// https://bugs.llvm.org/show_bug.cgi?id=34353
+// XFAIL: *
+
+struct B {
+ B() : p('B') {}
+ char p;
+};
+
+struct C {
+ const char *p;
+ explicit C(const char *c) : p(c) {}
+ C(const B &b) : p(&b.p) {} // NOLINT
+};
+
+struct A {
+ char p;
+ explicit A() : p('C') {}
+ const operator C() const { return C(&p); }
+};
+
+volatile char r;
+void test_a() {
+ C s = A();
+ r = *s.p;
+}
+
+void test_b() {
+ C s = B();
+ r = *s.p;
+}
+
+int main(int argc, char **argv) {
+ switch (argv[1][0]) {
+ case 'A':
+ test_a();
+ return 0;
+ case 'B':
+ test_b();
+ return 0;
+ }
+ return 1;
+}
+
+// CHECK: ERROR: AddressSanitizer: stack-use-after-scope
More information about the llvm-commits
mailing list