[libcxx-commits] [libcxx] [libcxx] Fix -Wshift-counter-overfliw in cxx03 bitset (PR #230208)
Aiden Grossman via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 8 09:50:12 PDT 2026
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/230208
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.
>From 6b39c4c794f9586c3981351fbbff48948d0068bc Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Thu, 8 Oct 2026 16:46:22 +0000
Subject: [PATCH] [libcxx] Fix -Wshift-counter-overfliw in cxx03 bitset
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.
---
libcxx/include/__cxx03/bitset | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
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);
More information about the libcxx-commits
mailing list