Skip to content

Commit 07c56fd

Browse files
committed
Apply @frederick-vs-ja suggestions to support 16-bit platforms
1 parent c1dfd79 commit 07c56fd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

libcxx/include/bitset

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,10 +382,12 @@ __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const {
382382
unsigned long long __r = __first_[0];
383383
_LIBCPP_DIAGNOSTIC_PUSH
384384
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wshift-count-overflow")
385+
// for (size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i)
386+
// __r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);
385387
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;
388+
const size_t __n_words = _N_words < __ull_words ? _N_words : __ull_words;
387389
for (size_t __i = 1; __i < __n_words; ++__i)
388-
__r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT * __i);
390+
__r |= static_cast<unsigned long long>(__first_[__i]) << (__bits_per_word * __i);
389391
_LIBCPP_DIAGNOSTIC_POP
390392
return __r;
391393
}

0 commit comments

Comments
 (0)