From 3b84f59b6bdf4ce57767aae4825788dba04e106f Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Tue, 2 Sep 2014 21:51:35 +0000 Subject: BumpPtrAllocator: use uintptr_t when aligning addresses to avoid undefined behaviour In theory, alignPtr() could push a pointer beyond the end of the current slab, making comparisons with that pointer undefined behaviour. Use an integer type to avoid this. llvm-svn: 216973 --- llvm/unittests/Support/AllocatorTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/unittests/Support/AllocatorTest.cpp') diff --git a/llvm/unittests/Support/AllocatorTest.cpp b/llvm/unittests/Support/AllocatorTest.cpp index dc224925fdd..7789df5dc6f 100644 --- a/llvm/unittests/Support/AllocatorTest.cpp +++ b/llvm/unittests/Support/AllocatorTest.cpp @@ -130,7 +130,7 @@ public: void *MemBase = malloc(Size + Alignment - 1 + sizeof(void*)); // Find the slab start. - void *Slab = alignPtr((char *)MemBase + sizeof(void *), Alignment); + void *Slab = (void *)alignAddr((char*)MemBase + sizeof(void *), Alignment); // Hold a pointer to the base so we can free the whole malloced block. ((void**)Slab)[-1] = MemBase; -- cgit v1.2.3