Skip to content

Commit 4d20d1e

Browse files
committed
Improve bitset::to_ullong Implementation
1 parent 6230f1b commit 4d20d1e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libcxx/include/bitset

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const {
381381
unsigned long long __r = __first_[0];
382382
_LIBCPP_DIAGNOSTIC_PUSH
383383
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wshift-count-overflow")
384-
for (size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i)
385-
__r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);
384+
for (size_t __i = 1; __i < _N_words; ++__i)
385+
__r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT * __i);
386386
_LIBCPP_DIAGNOSTIC_POP
387387
return __r;
388388
}

0 commit comments

Comments
 (0)