[ubsan] fix the test to me more resistent against changes in the sanitizer allocator

llvm-svn: 279661
This commit is contained in:
Kostya Serebryany 2016-08-24 21:03:28 +00:00
parent 75f0968b39
commit 6d03d84fac
1 changed files with 7 additions and 0 deletions

View File

@ -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<T*>(Buffer);