[libcxx-commits] [libcxx] [libcxx] Fix -Wshift-counter-overfliw in cxx03 bitset (PR #230208)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 8 09:50:52 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Aiden Grossman (boomanaiden154)
<details>
<summary>Changes</summary>
I thought 83ec4c471b462cb650ce947d7d6554df3256140a fixed this, but it turns out the gcc disablement was a red herring and clang was actually warning in a different spot. This commit reverts that commit and applies the disablement in the correct spot. I've actually tested that this fixes the frozen-cxx-03 headers job.
---
Full diff: https://github.com/llvm/llvm-project/pull/230208.diff
1 Files Affected:
- (modified) libcxx/include/__cxx03/bitset (+3-1)
``````````diff
diff --git a/libcxx/include/__cxx03/bitset b/libcxx/include/__cxx03/bitset
index 7d029f78a4382..1616eb8c87494 100644
--- a/libcxx/include/__cxx03/bitset
+++ b/libcxx/include/__cxx03/bitset
@@ -241,11 +241,14 @@ template <size_t _N_words, size_t _Size>
void __bitset<_N_words, _Size>::__init(unsigned long long __v, false_type) _NOEXCEPT {
__storage_type __t[sizeof(unsigned long long) / sizeof(__storage_type)];
size_t __sz = _Size;
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wshift-count-overflow")
for (size_t __i = 0; __i < sizeof(__t) / sizeof(__t[0]); ++__i, __v >>= __bits_per_word, __sz -= __bits_per_word)
if (__sz < __bits_per_word)
__t[__i] = static_cast<__storage_type>(__v) & (1ULL << __sz) - 1;
else
__t[__i] = static_cast<__storage_type>(__v);
+ _LIBCPP_DIAGNOSTIC_POP
std::copy(__t, __t + sizeof(__t) / sizeof(__t[0]), __first_);
std::fill(
@@ -339,7 +342,6 @@ template <size_t _N_words, size_t _Size>
_LIBCPP_HIDE_FROM_ABI unsigned long long __bitset<_N_words, _Size>::to_ullong(true_type, true_type) const {
unsigned long long __r = __first_[0];
_LIBCPP_DIAGNOSTIC_PUSH
- _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wshift-count-overflow")
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wshift-count-overflow")
for (size_t __i = 1; __i < sizeof(unsigned long long) / sizeof(__storage_type); ++__i)
__r |= static_cast<unsigned long long>(__first_[__i]) << (sizeof(__storage_type) * CHAR_BIT);
``````````
</details>
https://github.com/llvm/llvm-project/pull/230208
More information about the libcxx-commits
mailing list