[libcxx-commits] [libcxx] 428b320 - [libc++] Fix allocate_at_least test that assumes the size_type of the allocator (#131682)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 18 05:55:46 PDT 2025


Author: Louis Dionne
Date: 2025-03-18T08:55:43-04:00
New Revision: 428b320bf31329559ee9f8dd888be4f86cfa68e8

URL: https://github.com/llvm/llvm-project/commit/428b320bf31329559ee9f8dd888be4f86cfa68e8
DIFF: https://github.com/llvm/llvm-project/commit/428b320bf31329559ee9f8dd888be4f86cfa68e8.diff

LOG: [libc++] Fix allocate_at_least test that assumes the size_type of the allocator (#131682)

If the size_type of the allocator is not the same as std::size_t, this
test would fail.

Added: 
    

Modified: 
    libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_at_least.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_at_least.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_at_least.pass.cpp
index 88ae44c627584..8a9425a2ec9c2 100644
--- a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_at_least.pass.cpp
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_at_least.pass.cpp
@@ -45,16 +45,18 @@ struct has_allocate_at_least {
 constexpr bool test() {
   { // check that std::allocate_at_least forwards to allocator::allocate if no allocate_at_least exists
     no_allocate_at_least<int> alloc;
-    std::same_as<std::allocation_result<int*>> decltype(auto) ret =
-        std::allocator_traits<decltype(alloc)>::allocate_at_least(alloc, 1);
+    using AllocTraits = std::allocator_traits<decltype(alloc)>;
+    std::same_as<std::allocation_result<int*, AllocTraits::size_type>> decltype(auto) ret =
+        AllocTraits::allocate_at_least(alloc, 1);
     assert(ret.count == 1);
     assert(ret.ptr == &alloc.t);
   }
 
   { // check that std::allocate_at_least forwards to allocator::allocate_at_least if allocate_at_least exists
     has_allocate_at_least<int> alloc;
-    std::same_as<std::allocation_result<int*>> decltype(auto) ret =
-        std::allocator_traits<decltype(alloc)>::allocate_at_least(alloc, 1);
+    using AllocTraits = std::allocator_traits<decltype(alloc)>;
+    std::same_as<std::allocation_result<int*, AllocTraits::size_type>> decltype(auto) ret =
+        AllocTraits::allocate_at_least(alloc, 1);
     assert(ret.count == 2);
     assert(ret.ptr == &alloc.t2);
   }


        


More information about the libcxx-commits mailing list