[libcxx-commits] [libcxx] [libc++] Fix UB in bitwise logic of {std, ranges}::{fill, fill_n} algorithms (PR #122410)
Peng Liu via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jan 14 20:10:44 PST 2025
================
@@ -20,6 +22,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD
template <class _Cp, bool _IsConst, typename _Cp::__storage_type = 0>
class __bit_iterator;
+template <class _StorageType, __enable_if_t<is_unsigned<_StorageType>::value, int> = 0>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _StorageType __leading_mask(unsigned __shift) {
----------------
winner245 wrote:
You're right. Since I have introduced a new API `__fill_range_in_word` to set the given bit range of the `__bit_reference` to a given value following you next comment, the functions that create the bit masks are now incorporated into the new function `__fill_range_in_word`. Thus, in the PR, I don't need the functions `__leading_mask`, `__trailing_mask`, or `__middle_mask` any more and have been removed.
https://github.com/llvm/llvm-project/pull/122410
More information about the libcxx-commits
mailing list