[libcxx-commits] [libcxx] [libc++] Fix basic_string not allowing max_size() elements to be stored (PR #125423)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Feb 9 00:44:21 PST 2025
================
@@ -1305,10 +1305,10 @@ public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 size_type max_size() const _NOEXCEPT {
size_type __m = __alloc_traits::max_size(__alloc_);
if (__m <= std::numeric_limits<size_type>::max() / 2) {
- return __m - __alignment;
+ return __m - __alignment - 1;
} else {
bool __uses_lsb = __endian_factor == 2;
- return __uses_lsb ? __m - __alignment : (__m / 2) - __alignment;
+ return __uses_lsb ? __m - __alignment - 1 : (__m / 2) - __alignment - 1;
----------------
philnik777 wrote:
This is a bug fix as every other one is, and we usually don't release note them. What's different here?
https://github.com/llvm/llvm-project/pull/125423
More information about the libcxx-commits
mailing list