[libcxx-commits] [libcxx] [libc++][test] Fix invalid low-level const conversion in limited_allocator (PR #118189)
Peng Liu via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Nov 30 18:37:57 PST 2024
https://github.com/winner245 created https://github.com/llvm/llvm-project/pull/118189
This PR fixes an invalid low-level const conversion bug in `limited_allocator`. As this class is a widely used utility for testing allocator-aware containers, it is important to fix it. It is a very simple fix by just adding a const qualification.
The bug didn't crash our tests likely because our current usages of the template has not caused invocation to the specific member function. However, we can immediately trigger a compilation error through explicit template instantiation, or by using the operators == or !=.
>From fd10f6961fc16c793fca16550a4ef76363bb3de2 Mon Sep 17 00:00:00 2001
From: Peng Liu <winner245 at hotmail.com>
Date: Sat, 30 Nov 2024 21:20:59 -0500
Subject: [PATCH] Fix invalid low-level const conversion
---
libcxx/test/support/test_allocator.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcxx/test/support/test_allocator.h b/libcxx/test/support/test_allocator.h
index dcd15332ca304f..3bb14a6f381c47 100644
--- a/libcxx/test/support/test_allocator.h
+++ b/libcxx/test/support/test_allocator.h
@@ -467,7 +467,7 @@ class limited_allocator {
TEST_CONSTEXPR_CXX20 pointer allocate(size_type n) { return handle_->template allocate<T>(n); }
TEST_CONSTEXPR_CXX20 void deallocate(pointer p, size_type n) { handle_->template deallocate<T>(p, n); }
TEST_CONSTEXPR size_type max_size() const { return N; }
- TEST_CONSTEXPR BuffT* getHandle() const { return handle_.get(); }
+ TEST_CONSTEXPR const BuffT* getHandle() const { return handle_.get(); }
};
template <class T, class U, std::size_t N>
More information about the libcxx-commits
mailing list