[libcxx-commits] [libcxx] [libc++] Fix erroneous internal capacity evaluation in vector<bool> (PR #120577)
Peng Liu via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jan 5 20:24:54 PST 2025
================
@@ -115,7 +115,7 @@ class _LIBCPP_TEMPLATE_VIS vector<bool, _Allocator> {
}
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 static size_type
__external_cap_to_internal(size_type __n) _NOEXCEPT {
- return (__n - 1) / __bits_per_word + 1;
+ return (__n + __bits_per_word - 1) / __bits_per_word;
----------------
winner245 wrote:
In that case, maybe we should `return __n ? (__n - 1) / __bits_per_word + 1 : size_type(0);`?
https://github.com/llvm/llvm-project/pull/120577
More information about the libcxx-commits
mailing list