[libcxx] r271195 - Fix bug in test allocator that incorrectly computed the allocation size

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Sun May 29 18:31:07 PDT 2016


Author: ericwf
Date: Sun May 29 20:31:04 2016
New Revision: 271195

URL: http://llvm.org/viewvc/llvm-project?rev=271195&view=rev
Log:
Fix bug in test allocator that incorrectly computed the allocation size

Modified:
    libcxx/trunk/test/std/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/do_allocate_and_deallocate.pass.cpp
    libcxx/trunk/test/support/test_memory_resource.hpp

Modified: libcxx/trunk/test/std/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/do_allocate_and_deallocate.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/do_allocate_and_deallocate.pass.cpp?rev=271195&r1=271194&r2=271195&view=diff
==============================================================================
--- libcxx/trunk/test/std/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/do_allocate_and_deallocate.pass.cpp (original)
+++ libcxx/trunk/test/std/experimental/memory/memory.resource.adaptor/memory.resource.adaptor.mem/do_allocate_and_deallocate.pass.cpp Sun May 29 20:31:04 2016
@@ -34,7 +34,7 @@ void check_allocate_deallocate()
     typedef ex::resource_adaptor<Alloc> R1;
     const std::size_t max_align = alignof(std::max_align_t);
 
-    for (std::size_t s = 0; s < 5012; ++s)
+    for (std::size_t s = 1; s < 5012; ++s)
     {
         for(std::size_t align_req = 1; align_req <= (max_align * 2); align_req *= 2)
         {

Modified: libcxx/trunk/test/support/test_memory_resource.hpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_memory_resource.hpp?rev=271195&r1=271194&r2=271195&view=diff
==============================================================================
--- libcxx/trunk/test/support/test_memory_resource.hpp (original)
+++ libcxx/trunk/test/support/test_memory_resource.hpp Sun May 29 20:31:04 2016
@@ -16,6 +16,7 @@
 #include <cstddef>
 #include <cstdlib>
 #include <cstring>
+#include <cstdint>
 #include <cassert>
 #include "test_macros.h"
 
@@ -274,18 +275,18 @@ private:
         std::size_t bytes = (s + BlockSize - 1) & ~(BlockSize - 1);
         bytes += BlockSize;
         assert(bytes % BlockSize == 0);
-        return bytes / BlockSize;
+        return bytes;
     }
 
     static bool is_max_aligned(void* p) {
-        return reinterpret_cast<std::size_t>(p) % BlockSize == 0;
+        return reinterpret_cast<std::uintptr_t>(p) % BlockSize == 0;
     }
 
     static bool is_min_aligned(void* p) {
         if (alignof(T) == BlockSize) {
             return is_max_aligned(p);
         } else {
-            return reinterpret_cast<std::size_t>(p) % BlockSize == alignof(T);
+            return reinterpret_cast<std::uintptr_t>(p) % BlockSize == alignof(T);
         }
     }
 




More information about the cfe-commits mailing list