@@ -379,13 +379,13 @@ __bitset<_N_words, _Size>::to_ullong(true_type, false_type) const {
379379template <size_t _N_words, size_t _Size>
380380_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 unsigned long long
381381__bitset<_N_words, _Size>::to_ullong(true_type, true_type) const {
382- unsigned long long __r = __first_[0 ];
382+ unsigned long long __r = static_cast < unsigned long long >( __first_[0 ]) ;
383383 _LIBCPP_DIAGNOSTIC_PUSH
384384 _LIBCPP_GCC_DIAGNOSTIC_IGNORED (" -Wshift-count-overflow" )
385385 const size_t __ull_words = sizeof (unsigned long long ) / sizeof (__storage_type);
386- const size_t __n_words = _N_words < __ull_words ? _N_words : __ull_words;
386+ const size_t __n_words = _N_words < __ull_words ? _N_words : __ull_words;
387387 for (size_t __i = 1 ; __i < __n_words; ++__i)
388- __r |= static_cast <unsigned long long >(__first_[__i]) << (sizeof (__storage_type) * CHAR_BIT * __i);
388+ __r |= static_cast <unsigned long long >(__first_[__i]) << (__bits_per_word * __i);
389389 _LIBCPP_DIAGNOSTIC_POP
390390 return __r;
391391}
@@ -494,8 +494,7 @@ inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset() _NOEXCEPT : __first_(0)
494494
495495template <size_t _Size>
496496inline _LIBCPP_CONSTEXPR __bitset<1 , _Size>::__bitset(unsigned long long __v) _NOEXCEPT
497- : __first_(_Size == __bits_per_word ? static_cast <__storage_type>(__v)
498- : static_cast <__storage_type>(__v) & ((__storage_type(1 ) << _Size) - 1 )) {}
497+ : __first_(static_cast <__storage_type>(__v)) {}
499498
500499template <size_t _Size>
501500inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 void
@@ -626,7 +625,8 @@ public:
626625
627626 // 23.3.5.1 constructors:
628627 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset () _NOEXCEPT {}
629- _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset (unsigned long long __v) _NOEXCEPT : __base(__v) {}
628+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR bitset (unsigned long long __v) _NOEXCEPT
629+ : __base(sizeof (unsigned long long ) * CHAR_BIT <= _Size ? __v : __v & ((1ULL << _Size) - 1)) {}
630630 template <class _CharT , __enable_if_t <_IsCharLikeType<_CharT>::value, int > = 0 >
631631 _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX23 explicit bitset (
632632 const _CharT* __str,
0 commit comments