Skip to content

Conversation

@ldionne
Copy link
Member

@ldionne ldionne commented Mar 17, 2025

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

… allocator

If the size_type of the allocator is not the same as std::size_t, this
test would fail.
@ldionne ldionne requested a review from a team as a code owner March 17, 2025 22:01
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Mar 17, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 17, 2025

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/131682.diff

1 Files Affected:

  • (modified) libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_at_least.pass.cpp (+6-4)
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..ee899dcb3e66d 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);
   }

@ldionne ldionne merged commit 428b320 into llvm:main Mar 18, 2025
85 checks passed
@ldionne ldionne deleted the review/fix-allocate_at_least-test branch March 18, 2025 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants