Skip to content

Commit 6d03d84

Browse files
committed
[ubsan] fix the test to me more resistent against changes in the sanitizer allocator
llvm-svn: 279661
1 parent 75f0968 commit 6d03d84

File tree

1 file changed

+7
-0
lines changed
  • compiler-rt/test/ubsan/TestCases/TypeCheck

1 file changed

+7
-0
lines changed

compiler-rt/test/ubsan/TestCases/TypeCheck/vptr.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ struct V : S {};
5050
// Make p global so that lsan does not complain.
5151
T *p = 0;
5252

53+
volatile void *sink1, *sink2;
54+
5355
int access_p(T *p, char type);
5456

5557
int main(int argc, char **argv) {
@@ -74,6 +76,11 @@ int main(int argc, char **argv) {
7476

7577
char Buffer[sizeof(U)] = {};
7678
char TStorage[sizeof(T)];
79+
// Allocate two dummy objects so that the real object
80+
// is not on the boundary of mapped memory. Otherwise ubsan
81+
// will not be able to describe the vptr in detail.
82+
sink1 = new T;
83+
sink2 = new U;
7784
switch (argv[1][1]) {
7885
case '0':
7986
p = reinterpret_cast<T*>(Buffer);

0 commit comments

Comments
 (0)