From 6d03d84fac57c1ff6ce29acfe028b19a3e639ff7 Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Wed, 24 Aug 2016 21:03:28 +0000 Subject: [PATCH] [ubsan] fix the test to me more resistent against changes in the sanitizer allocator llvm-svn: 279661 --- compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp b/compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp index 86b646da7561..62fb4ed08238 100644 --- a/compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp +++ b/compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp @@ -50,6 +50,8 @@ struct V : S {}; // Make p global so that lsan does not complain. T *p = 0; +volatile void *sink1, *sink2; + int access_p(T *p, char type); int main(int argc, char **argv) { @@ -74,6 +76,11 @@ int main(int argc, char **argv) { char Buffer[sizeof(U)] = {}; char TStorage[sizeof(T)]; + // Allocate two dummy objects so that the real object + // is not on the boundary of mapped memory. Otherwise ubsan + // will not be able to describe the vptr in detail. + sink1 = new T; + sink2 = new U; switch (argv[1][1]) { case '0': p = reinterpret_cast(Buffer);