Skip to content

[libc] Add -Wno-sign-conversion & re-attempt -Wconversion #129811

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Mar 10, 2025

Conversation

vinay-deshmukh
Copy link
Contributor

@vinay-deshmukh vinay-deshmukh commented Mar 5, 2025

Relates to #119281 (comment)

Copy link

github-actions bot commented Mar 5, 2025

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Discourse for more information.

@@ -285,7 +285,10 @@ LIBC_INLINE constexpr cpp::array<word, N> shift(cpp::array<word, N> array,
return 0;
if (i >= int(N))
return is_neg ? cpp::numeric_limits<word>::max() : 0;
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
return array[i];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only code that get flagged (atleast locally for an overlay build).

it was changed to use size_t in: #127523

but had to be reverted in: #129771 (comment)

Discussion on why it needs signed int has begun here: #129771 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: pragma(s) are only WIP for now, will be fixed in final version of PR based on above discussion

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be a simpler solution:

Suggested change
return array[i];
return static_cast<word>(array[i]);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This didn't work, as the error is at:

llvm-project/libc/src/__support/big_int.h:288:36: error: implicit conversion changes signedness: 'const int' to 'size_t' (aka 'unsigned long') [-Werror,-Wsign-conversion]
    return static_cast<word>(array[i]);

But:

Suggested change
return array[i];
return array[static_cast<size_t>(i)];

did work

Copy link

github-actions bot commented Mar 5, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@vinay-deshmukh vinay-deshmukh force-pushed the vinay-issue-119281-sign-conversion branch from 0d17ad6 to 958813a Compare March 6, 2025 01:29
@vinay-deshmukh vinay-deshmukh changed the title [libc] Add -Wsign-conversion [libc] Add -Wsign-conversion & un-reverts -Wconversion Mar 6, 2025
# list(APPEND compile_options "-Wconversion")
# list(APPEND compile_options "-Wno-sign-conversion")
list(APPEND compile_options "-Wconversion")
list(APPEND compile_options "-Wsign-conversion")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because -Wno-sign-conversion is effectively "silencing" it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried this PR and there are still many warnings from -Wsign-conversion:

$ ninja check-libc &> test.txt
$ grep -c "Wsign-conversion" test.txt
12651

Some example:

In file included from /usr/local/google/home/lntue/experiment/llvm-project/libc/src/__support/FPUtil/FEnvImpl.h:31:
/usr/local/google/home/lntue/experiment/llvm-project/libc/src/__support/FPUtil/x86_64/FEnvImpl.h:169:12: warning: implicit conversion changes signedness: 'int' to 'uint32_t' (aka 'unsigned int') [-Wsign-conversion]
  mxcsr &= ~(bit_mask << internal::MXCSR_EXCEPTION_CONTOL_BIT_POISTION);
        ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/lntue/experiment/llvm-project/libc/src/__support/FPUtil/x86_64/FEnvImpl.h:193:22: warning: implicit conversion changes signedness: 'int' to 'uint32_t' (aka 'unsigned int') [-Wsign-conversion]
  mxcsr |= (bit_mask << internal::MXCSR_EXCEPTION_CONTOL_BIT_POISTION);
        ~~  ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/lntue/experiment/llvm-project/libc/src/__support/FPUtil/x86_64/FEnvImpl.h:341:26: warning: implicit conversion changes signedness: 'int' to 'uint32_t' (aka 'unsigned int') [-Wsign-conversion]
                         << internal::MXCSR_ROUNDING_CONTROL_BIT_POSITION;
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/lntue/experiment/llvm-project/libc/src/__support/FPUtil/x86_64/FEnvImpl.h:344:20: warning: implicit conversion changes signedness: 'int' to 'uint32_t' (aka 'unsigned int') [-Wsign-conversion]
                   ~(0x3 << internal::MXCSR_ROUNDING_CONTROL_BIT_POSITION)) |
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/lntue/experiment/llvm-project/libc/src/__support/FPUtil/x86_64/FEnvImpl.h:610:14: warning: implicit conversion changes signedness: 'int' to 'uint32_t' (aka 'unsigned int') [-Wsign-conversion]
    mxcsr &= ~uint16_t(0x3F);        // Clear exception flags.
          ~~ ^~~~~~~~~~~~~~~
/usr/local/google/home/lntue/experiment/llvm-project/libc/src/__support/FPUtil/x86_64/FEnvImpl.h:611:14: warning: implicit conversion changes signedness: 'int' to 'uint32_t' (aka 'unsigned int') [-Wsign-conversion]
    mxcsr &= ~(uint16_t(0x1) << 6);  // Reset denormals-are-zero
          ~~ ^~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/lntue/experiment/llvm-project/libc/src/__support/FPUtil/x86_64/FEnvImpl.h:613:14: warning: implicit conversion changes signedness: 'int' to 'uint32_t' (aka 'unsigned int') [-Wsign-conversion]
    mxcsr &= ~(uint16_t(0x3) << 13); // Round to nearest.
          ~~ ^~~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/lntue/experiment/llvm-project/libc/src/__support/FPUtil/x86_64/FEnvImpl.h:614:14: warning: implicit conversion changes signedness: 'int' to 'uint32_t' (aka 'unsigned int') [-Wsign-conversion]
    mxcsr &= ~(uint16_t(0x1) << 15); // Reset flush-to-zero
          ~~ ^~~~~~~~~~~~~~~~~~~~~~

Probably you should change to -Wno-sign-conversion in this PR, add a TODO comment to clean it up, and then fix the remaining -Wsign-conversion in a followup PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way to reproduce these in the PR checks?

I don't have a x86 64 machine at the moment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made it -Wno-sign-conversion

@vinay-deshmukh vinay-deshmukh marked this pull request as ready for review March 7, 2025 11:35
@llvmbot llvmbot added the libc label Mar 7, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 7, 2025

@llvm/pr-subscribers-libc

Author: Vinay Deshmukh (vinay-deshmukh)

Changes

Relates to #119281 (comment)


Patch is 72.93 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/129811.diff

47 Files Affected:

  • (modified) libc/cmake/modules/LLVMLibCTestRules.cmake (+2-2)
  • (modified) libc/src/__support/CPP/bit.h (+4-4)
  • (modified) libc/src/__support/CPP/span.h (+4-2)
  • (modified) libc/src/__support/CPP/string.h (+2-1)
  • (modified) libc/src/__support/CPP/string_view.h (+4-2)
  • (modified) libc/src/__support/FPUtil/FPBits.h (+3-3)
  • (modified) libc/src/__support/FPUtil/NormalFloat.h (+2-2)
  • (modified) libc/src/__support/FPUtil/aarch64/FEnvImpl.h (+7-5)
  • (modified) libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h (+23-16)
  • (modified) libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h (+1-1)
  • (modified) libc/src/__support/OSUtil/darwin/io.h (+2-1)
  • (modified) libc/src/__support/big_int.h (+15-12)
  • (modified) libc/src/__support/high_precision_decimal.h (+7-7)
  • (modified) libc/src/__support/integer_literals.h (+1-1)
  • (modified) libc/src/__support/integer_to_string.h (+3-2)
  • (modified) libc/src/__support/memory_size.h (+2-1)
  • (modified) libc/src/__support/str_to_float.h (+12-12)
  • (modified) libc/src/__support/str_to_integer.h (+6-6)
  • (modified) libc/src/stdio/printf_core/parser.h (+10-8)
  • (modified) libc/src/stdio/printf_core/writer.h (+2-1)
  • (modified) libc/src/stdio/scanf_core/parser.h (+7-6)
  • (modified) libc/src/stdlib/quick_sort.h (+3-1)
  • (modified) libc/src/string/memory_utils/utils.h (+4-3)
  • (modified) libc/src/string/string_utils.h (+8-6)
  • (modified) libc/test/UnitTest/ExecuteFunction.h (+4-4)
  • (modified) libc/test/UnitTest/ExecuteFunctionUnix.cpp (+1-1)
  • (modified) libc/test/UnitTest/LibcTest.cpp (+2-2)
  • (modified) libc/test/UnitTest/MemoryMatcher.h (+1-1)
  • (modified) libc/test/src/__support/CPP/bit_test.cpp (+10-7)
  • (modified) libc/test/src/__support/arg_list_test.cpp (+5-4)
  • (modified) libc/test/src/__support/big_int_test.cpp (+4-4)
  • (modified) libc/test/src/__support/blockstore_test.cpp (+1-1)
  • (modified) libc/test/src/__support/fixedvector_test.cpp (+2-2)
  • (modified) libc/test/src/__support/hash_test.cpp (+1-1)
  • (modified) libc/test/src/__support/integer_to_string_test.cpp (+6-5)
  • (modified) libc/test/src/__support/math_extras_test.cpp (+17-11)
  • (modified) libc/test/src/__support/str_to_double_test.cpp (+1-1)
  • (modified) libc/test/src/__support/str_to_float_test.cpp (+1-1)
  • (modified) libc/test/src/__support/str_to_fp_test.h (+3-3)
  • (modified) libc/test/src/math/FModTest.h (+4-4)
  • (modified) libc/test/src/stdio/printf_core/parser_test.cpp (+40-20)
  • (modified) libc/test/src/string/memmove_test.cpp (+2-1)
  • (modified) libc/test/src/string/memory_utils/memory_check_utils.h (+5-3)
  • (modified) libc/test/src/string/memory_utils/op_tests.cpp (+2-2)
  • (modified) libc/test/src/string/memory_utils/utils_test.cpp (+2-2)
  • (modified) libc/test/src/string/memset_test.cpp (+1-1)
  • (modified) libc/test/src/strings/bcopy_test.cpp (+2-1)
diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 03b4b251649e7..d332d5d044045 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -36,8 +36,8 @@ function(_get_common_test_compile_options output_var c_test flags)
     if(NOT LIBC_WNO_ERROR)
       # list(APPEND compile_options "-Werror")
     endif()
-    # list(APPEND compile_options "-Wconversion")
-    # list(APPEND compile_options "-Wno-sign-conversion")
+    list(APPEND compile_options "-Wconversion")
+    list(APPEND compile_options "-Wsign-conversion")
     list(APPEND compile_options "-Wimplicit-fallthrough")
     list(APPEND compile_options "-Wwrite-strings")
     # Silence this warning because _Complex is a part of C99.
diff --git a/libc/src/__support/CPP/bit.h b/libc/src/__support/CPP/bit.h
index 82b9eb5128262..7d138201783bf 100644
--- a/libc/src/__support/CPP/bit.h
+++ b/libc/src/__support/CPP/bit.h
@@ -101,7 +101,7 @@ countr_zero(T value) {
     shift >>= 1;
     mask >>= shift;
   }
-  return zero_bits;
+  return static_cast<int>(zero_bits);
 }
 #if __has_builtin(__builtin_ctzs)
 ADD_SPECIALIZATION(countr_zero, unsigned short, __builtin_ctzs)
@@ -140,7 +140,7 @@ countl_zero(T value) {
     else
       zero_bits |= shift;
   }
-  return zero_bits;
+  return static_cast<int>(zero_bits);
 }
 #if __has_builtin(__builtin_clzs)
 ADD_SPECIALIZATION(countl_zero, unsigned short, __builtin_clzs)
@@ -226,7 +226,7 @@ rotr(T value, int rotate);
 template <typename T>
 [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T>
 rotl(T value, int rotate) {
-  constexpr unsigned N = cpp::numeric_limits<T>::digits;
+  constexpr int N = cpp::numeric_limits<T>::digits;
   rotate = rotate % N;
   if (!rotate)
     return value;
@@ -238,7 +238,7 @@ rotl(T value, int rotate) {
 template <typename T>
 [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, T>
 rotr(T value, int rotate) {
-  constexpr unsigned N = cpp::numeric_limits<T>::digits;
+  constexpr int N = cpp::numeric_limits<T>::digits;
   rotate = rotate % N;
   if (!rotate)
     return value;
diff --git a/libc/src/__support/CPP/span.h b/libc/src/__support/CPP/span.h
index a41c9b744e370..9234a26d201cd 100644
--- a/libc/src/__support/CPP/span.h
+++ b/libc/src/__support/CPP/span.h
@@ -11,6 +11,7 @@
 #include <stddef.h> // For size_t
 
 #include "array.h" // For array
+#include "limits.h"
 #include "src/__support/macros/config.h"
 #include "type_traits.h" // For remove_cv_t, enable_if_t, is_same_v, is_const_v
 
@@ -48,7 +49,8 @@ template <typename T> class span {
   using const_reference = const T &;
   using iterator = T *;
 
-  LIBC_INLINE_VAR static constexpr size_type dynamic_extent = -1;
+  LIBC_INLINE_VAR static constexpr size_type dynamic_extent =
+      cpp::numeric_limits<size_type>::max();
 
   LIBC_INLINE constexpr span() : span_data(nullptr), span_size(0) {}
 
@@ -58,7 +60,7 @@ template <typename T> class span {
       : span_data(first), span_size(count) {}
 
   LIBC_INLINE constexpr span(pointer first, pointer end)
-      : span_data(first), span_size(end - first) {}
+      : span_data(first), span_size(static_cast<size_t>(end - first)) {}
 
   template <typename U, size_t N,
             cpp::enable_if_t<is_compatible_v<U>, bool> = true>
diff --git a/libc/src/__support/CPP/string.h b/libc/src/__support/CPP/string.h
index dbc0ae04e5e6f..1ac04c7f1f9dc 100644
--- a/libc/src/__support/CPP/string.h
+++ b/libc/src/__support/CPP/string.h
@@ -67,7 +67,8 @@ class string {
       : string(cstr, ::LIBC_NAMESPACE::internal::string_length(cstr)) {}
   LIBC_INLINE string(size_t size_, char value) {
     resize(size_);
-    inline_memset((void *)buffer_, value, size_);
+    static_assert(sizeof(char) == sizeof(uint8_t));
+    inline_memset((void *)buffer_, static_cast<uint8_t>(value), size_);
   }
 
   LIBC_INLINE string &operator=(const string &other) {
diff --git a/libc/src/__support/CPP/string_view.h b/libc/src/__support/CPP/string_view.h
index 745c62c35f0a0..aa15814b2e149 100644
--- a/libc/src/__support/CPP/string_view.h
+++ b/libc/src/__support/CPP/string_view.h
@@ -9,6 +9,7 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_STRING_VIEW_H
 #define LLVM_LIBC_SRC___SUPPORT_CPP_STRING_VIEW_H
 
+#include "limits.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 
@@ -40,7 +41,7 @@ class string_view {
   LIBC_INLINE static constexpr size_t length(const char *Str) {
     for (const char *End = Str;; ++End)
       if (*End == '\0')
-        return End - Str;
+        return static_cast<size_t>(End - Str);
   }
 
   LIBC_INLINE bool equals(string_view Other) const {
@@ -61,7 +62,8 @@ class string_view {
 
   // special value equal to the maximum value representable by the type
   // size_type.
-  LIBC_INLINE_VAR static constexpr size_t npos = -1;
+  LIBC_INLINE_VAR static constexpr size_t npos =
+      cpp::numeric_limits<size_t>::max();
 
   LIBC_INLINE constexpr string_view() : Data(nullptr), Len(0) {}
 
diff --git a/libc/src/__support/FPUtil/FPBits.h b/libc/src/__support/FPUtil/FPBits.h
index 90b6e406e0f31..bee8d0a8dc47d 100644
--- a/libc/src/__support/FPUtil/FPBits.h
+++ b/libc/src/__support/FPUtil/FPBits.h
@@ -247,11 +247,11 @@ template <FPType fp_type> struct FPStorage : public FPLayout<fp_type> {
     using UP::UP;
 
     LIBC_INLINE constexpr BiasedExponent(Exponent exp)
-        : UP(static_cast<int32_t>(exp) + EXP_BIAS) {}
+        : UP(static_cast<uint32_t>(static_cast<int32_t>(exp) + EXP_BIAS)) {}
 
     // Cast operator to get convert from BiasedExponent to Exponent.
     LIBC_INLINE constexpr operator Exponent() const {
-      return Exponent(UP::value - EXP_BIAS);
+      return Exponent(static_cast<int32_t>(UP::value - EXP_BIAS));
     }
 
     LIBC_INLINE constexpr BiasedExponent &operator++() {
@@ -686,7 +686,7 @@ struct FPRepImpl : public FPRepSem<fp_type, RetT> {
   }
 
   LIBC_INLINE constexpr void set_biased_exponent(StorageType biased) {
-    UP::set_biased_exponent(BiasedExponent((int32_t)biased));
+    UP::set_biased_exponent(BiasedExponent(static_cast<uint32_t>(biased)));
   }
 
   LIBC_INLINE constexpr int get_exponent() const {
diff --git a/libc/src/__support/FPUtil/NormalFloat.h b/libc/src/__support/FPUtil/NormalFloat.h
index b4cbb5042a68b..a2f285fc6fb95 100644
--- a/libc/src/__support/FPUtil/NormalFloat.h
+++ b/libc/src/__support/FPUtil/NormalFloat.h
@@ -105,7 +105,7 @@ template <typename T> struct NormalFloat {
 
     constexpr int SUBNORMAL_EXPONENT = -FPBits<T>::EXP_BIAS + 1;
     if (exponent < SUBNORMAL_EXPONENT) {
-      unsigned shift = SUBNORMAL_EXPONENT - exponent;
+      unsigned shift = static_cast<unsigned>(SUBNORMAL_EXPONENT - exponent);
       // Since exponent > subnormalExponent, shift is strictly greater than
       // zero.
       if (shift <= FPBits<T>::FRACTION_LEN + 1) {
@@ -160,7 +160,7 @@ template <typename T> struct NormalFloat {
     if (bits.is_subnormal()) {
       unsigned shift = evaluate_normalization_shift(bits.get_mantissa());
       mantissa = static_cast<StorageType>(bits.get_mantissa() << shift);
-      exponent = 1 - FPBits<T>::EXP_BIAS - shift;
+      exponent = 1 - FPBits<T>::EXP_BIAS - static_cast<int32_t>(shift);
     } else {
       exponent = bits.get_biased_exponent() - FPBits<T>::EXP_BIAS;
       mantissa = ONE | bits.get_mantissa();
diff --git a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
index 18b0631324f8f..914155a01631d 100644
--- a/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
+++ b/libc/src/__support/FPUtil/aarch64/FEnvImpl.h
@@ -110,7 +110,7 @@ LIBC_INLINE int enable_except(int excepts) {
       (controlWord >> FEnv::ExceptionControlFlagsBitPosition) & 0x1F;
   controlWord |= (newExcepts << FEnv::ExceptionControlFlagsBitPosition);
   FEnv::writeControlWord(controlWord);
-  return FEnv::exceptionStatusToMacro(oldExcepts);
+  return FEnv::exceptionStatusToMacro(static_cast<uint32_t>(oldExcepts));
 }
 
 LIBC_INLINE int disable_except(int excepts) {
@@ -120,12 +120,12 @@ LIBC_INLINE int disable_except(int excepts) {
       (controlWord >> FEnv::ExceptionControlFlagsBitPosition) & 0x1F;
   controlWord &= ~(disabledExcepts << FEnv::ExceptionControlFlagsBitPosition);
   FEnv::writeControlWord(controlWord);
-  return FEnv::exceptionStatusToMacro(oldExcepts);
+  return FEnv::exceptionStatusToMacro(static_cast<uint32_t>(oldExcepts));
 }
 
 LIBC_INLINE int get_except() {
   uint32_t controlWord = FEnv::getControlWord();
-  int enabledExcepts =
+  uint32_t enabledExcepts =
       (controlWord >> FEnv::ExceptionControlFlagsBitPosition) & 0x1F;
   return FEnv::exceptionStatusToMacro(enabledExcepts);
 }
@@ -250,8 +250,10 @@ LIBC_INLINE int set_round(int mode) {
   }
 
   uint32_t controlWord = FEnv::getControlWord();
-  controlWord &= ~(0x3 << FEnv::RoundingControlBitPosition);
-  controlWord |= (bitValue << FEnv::RoundingControlBitPosition);
+  controlWord &=
+      static_cast<uint32_t>(~(0x3 << FEnv::RoundingControlBitPosition));
+  controlWord |=
+      static_cast<uint32_t>(bitValue << FEnv::RoundingControlBitPosition);
   FEnv::writeControlWord(controlWord);
 
   return 0;
diff --git a/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h b/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
index 969e70796d1f1..dcce76b6116be 100644
--- a/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
+++ b/libc/src/__support/FPUtil/aarch64/fenv_darwin_impl.h
@@ -63,7 +63,7 @@ struct FEnv {
   // __fpcr_flush_to_zero bit in the FPCR register.  This control bit is
   // located in a different place from FE_FLUSHTOZERO status bit relative to
   // the other exceptions.
-  LIBC_INLINE static uint32_t exception_value_from_status(int status) {
+  LIBC_INLINE static uint32_t exception_value_from_status(uint32_t status) {
     return ((status & FE_INVALID) ? EX_INVALID : 0) |
            ((status & FE_DIVBYZERO) ? EX_DIVBYZERO : 0) |
            ((status & FE_OVERFLOW) ? EX_OVERFLOW : 0) |
@@ -72,7 +72,7 @@ struct FEnv {
            ((status & FE_FLUSHTOZERO) ? EX_FLUSHTOZERO : 0);
   }
 
-  LIBC_INLINE static uint32_t exception_value_from_control(int control) {
+  LIBC_INLINE static uint32_t exception_value_from_control(uint32_t control) {
     return ((control & __fpcr_trap_invalid) ? EX_INVALID : 0) |
            ((control & __fpcr_trap_divbyzero) ? EX_DIVBYZERO : 0) |
            ((control & __fpcr_trap_overflow) ? EX_OVERFLOW : 0) |
@@ -81,7 +81,7 @@ struct FEnv {
            ((control & __fpcr_flush_to_zero) ? EX_FLUSHTOZERO : 0);
   }
 
-  LIBC_INLINE static int exception_value_to_status(uint32_t excepts) {
+  LIBC_INLINE static uint32_t exception_value_to_status(uint32_t excepts) {
     return ((excepts & EX_INVALID) ? FE_INVALID : 0) |
            ((excepts & EX_DIVBYZERO) ? FE_DIVBYZERO : 0) |
            ((excepts & EX_OVERFLOW) ? FE_OVERFLOW : 0) |
@@ -90,7 +90,7 @@ struct FEnv {
            ((excepts & EX_FLUSHTOZERO) ? FE_FLUSHTOZERO : 0);
   }
 
-  LIBC_INLINE static int exception_value_to_control(uint32_t excepts) {
+  LIBC_INLINE static uint32_t exception_value_to_control(uint32_t excepts) {
     return ((excepts & EX_INVALID) ? __fpcr_trap_invalid : 0) |
            ((excepts & EX_DIVBYZERO) ? __fpcr_trap_divbyzero : 0) |
            ((excepts & EX_OVERFLOW) ? __fpcr_trap_overflow : 0) |
@@ -113,34 +113,37 @@ struct FEnv {
 };
 
 LIBC_INLINE int enable_except(int excepts) {
-  uint32_t new_excepts = FEnv::exception_value_from_status(excepts);
+  uint32_t new_excepts =
+      FEnv::exception_value_from_status(static_cast<uint32_t>(excepts));
   uint32_t control_word = FEnv::get_control_word();
   uint32_t old_excepts = FEnv::exception_value_from_control(control_word);
   if (new_excepts != old_excepts) {
     control_word |= FEnv::exception_value_to_control(new_excepts);
     FEnv::set_control_word(control_word);
   }
-  return FEnv::exception_value_to_status(old_excepts);
+  return static_cast<int>(FEnv::exception_value_to_status(old_excepts));
 }
 
 LIBC_INLINE int disable_except(int excepts) {
-  uint32_t disabled_excepts = FEnv::exception_value_from_status(excepts);
+  uint32_t disabled_excepts =
+      FEnv::exception_value_from_status(static_cast<uint32_t>(excepts));
   uint32_t control_word = FEnv::get_control_word();
   uint32_t old_excepts = FEnv::exception_value_from_control(control_word);
   control_word &= ~FEnv::exception_value_to_control(disabled_excepts);
   FEnv::set_control_word(control_word);
-  return FEnv::exception_value_to_status(old_excepts);
+  return static_cast<int>(FEnv::exception_value_to_status(old_excepts));
 }
 
 LIBC_INLINE int get_except() {
   uint32_t control_word = FEnv::get_control_word();
   uint32_t enabled_excepts = FEnv::exception_value_from_control(control_word);
-  return FEnv::exception_value_to_status(enabled_excepts);
+  return static_cast<int>(FEnv::exception_value_to_status(enabled_excepts));
 }
 
 LIBC_INLINE int clear_except(int excepts) {
   uint32_t status_word = FEnv::get_status_word();
-  uint32_t except_value = FEnv::exception_value_from_status(excepts);
+  uint32_t except_value =
+      FEnv::exception_value_from_status(static_cast<uint32_t>(excepts));
   status_word &= ~FEnv::exception_value_to_status(except_value);
   FEnv::set_status_word(status_word);
   return 0;
@@ -148,13 +151,16 @@ LIBC_INLINE int clear_except(int excepts) {
 
 LIBC_INLINE int test_except(int excepts) {
   uint32_t statusWord = FEnv::get_status_word();
-  uint32_t ex_value = FEnv::exception_value_from_status(excepts);
-  return statusWord & FEnv::exception_value_to_status(ex_value);
+  uint32_t ex_value =
+      FEnv::exception_value_from_status(static_cast<uint32_t>(excepts));
+  return static_cast<int>(statusWord &
+                          FEnv::exception_value_to_status(ex_value));
 }
 
 LIBC_INLINE int set_except(int excepts) {
   uint32_t status_word = FEnv::get_status_word();
-  uint32_t new_exceptions = FEnv::exception_value_from_status(excepts);
+  uint32_t new_exceptions =
+      FEnv::exception_value_from_status(static_cast<uint32_t>(excepts));
   status_word |= FEnv::exception_value_to_status(new_exceptions);
   FEnv::set_status_word(status_word);
   return 0;
@@ -174,7 +180,8 @@ LIBC_INLINE int raise_except(int excepts) {
                          : "s0", "s1" /* s0 and s1 are clobbered */);
   };
 
-  uint32_t to_raise = FEnv::exception_value_from_status(excepts);
+  uint32_t to_raise =
+      FEnv::exception_value_from_status(static_cast<uint32_t>(excepts));
   int result = 0;
 
   if (to_raise & FEnv::EX_INVALID) {
@@ -237,7 +244,7 @@ LIBC_INLINE int get_round() {
 }
 
 LIBC_INLINE int set_round(int mode) {
-  uint16_t bit_value;
+  uint32_t bit_value;
   switch (mode) {
   case FE_TONEAREST:
     bit_value = FEnv::TONEAREST;
@@ -256,7 +263,7 @@ LIBC_INLINE int set_round(int mode) {
   }
 
   uint32_t control_word = FEnv::get_control_word();
-  control_word &= ~(0x3 << FEnv::ROUNDING_CONTROL_BIT_POSITION);
+  control_word &= ~(0x3u << FEnv::ROUNDING_CONTROL_BIT_POSITION);
   control_word |= (bit_value << FEnv::ROUNDING_CONTROL_BIT_POSITION);
   FEnv::set_control_word(control_word);
 
diff --git a/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h b/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
index 9492d52da0455..0ba836d17a085 100644
--- a/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
+++ b/libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h
@@ -24,7 +24,7 @@ namespace x86 {
 LIBC_INLINE void normalize(int &exponent,
                            FPBits<long double>::StorageType &mantissa) {
   const unsigned int shift = static_cast<unsigned int>(
-      cpp::countl_zero(static_cast<uint64_t>(mantissa)) -
+      static_cast<size_t>(cpp::countl_zero(static_cast<uint64_t>(mantissa))) -
       (8 * sizeof(uint64_t) - 1 - FPBits<long double>::FRACTION_LEN));
   exponent -= shift;
   mantissa <<= shift;
diff --git a/libc/src/__support/OSUtil/darwin/io.h b/libc/src/__support/OSUtil/darwin/io.h
index a5f7ecbd70362..69df99da522fb 100644
--- a/libc/src/__support/OSUtil/darwin/io.h
+++ b/libc/src/__support/OSUtil/darwin/io.h
@@ -17,7 +17,8 @@ namespace LIBC_NAMESPACE_DECL {
 
 LIBC_INLINE void write_to_stderr(cpp::string_view msg) {
   LIBC_NAMESPACE::syscall_impl(4 /*SYS_write*/, 2 /* stderr */,
-                               reinterpret_cast<long>(msg.data()), msg.size());
+                               reinterpret_cast<long>(msg.data()),
+                               static_cast<long>(msg.size()));
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/__support/big_int.h b/libc/src/__support/big_int.h
index e726a094b5dac..04e9f3cf656a1 100644
--- a/libc/src/__support/big_int.h
+++ b/libc/src/__support/big_int.h
@@ -284,8 +284,8 @@ LIBC_INLINE constexpr cpp::array<word, N> shift(cpp::array<word, N> array,
     if (i < 0)
       return 0;
     if (i >= int(N))
-      return is_neg ? -1 : 0;
-    return array[i];
+      return is_neg ? cpp::numeric_limits<word>::max() : 0;
+    return array[static_cast<size_t>(i)];
   };
   const size_t index_offset = offset / WORD_BITS;
   const size_t bit_offset = offset % WORD_BITS;
@@ -296,7 +296,7 @@ LIBC_INLINE constexpr cpp::array<word, N> shift(cpp::array<word, N> array,
   for (size_t index = 0; index < N; ++index) {
     const word part1 = safe_get_at(index + index_offset);
     const word part2 = safe_get_at(index + index_offset + 1);
-    word &dst = out[at(index)];
+    word &dst = out[static_cast<size_t>(at(index))];
     if (bit_offset == 0)
       dst = part1; // no crosstalk between parts.
     else if constexpr (direction == LEFT)
@@ -696,7 +696,8 @@ struct BigInt {
     }
     BigInt quotient;
     WordType x_word = static_cast<WordType>(x);
-    constexpr size_t LOG2_WORD_SIZE = cpp::bit_width(WORD_SIZE) - 1;
+    constexpr size_t LOG2_WORD_SIZE =
+        static_cast<size_t>(cpp::bit_width(WORD_SIZE) - 1);
     constexpr size_t HALF_WORD_SIZE = WORD_SIZE >> 1;
     constexpr WordType HALF_MASK = ((WordType(1) << HALF_WORD_SIZE) - 1);
     // lower = smallest multiple of WORD_SIZE that is >= e.
@@ -1008,12 +1009,12 @@ struct BigInt {
       BigInt subtractor = divider;
       int cur_bit = multiword::countl_zero(subtractor.val) -
                     multiword::countl_zero(remainder.val);
-      subtractor <<= cur_bit;
+      subtractor <<= static_cast<size_t>(cur_bit);
       for (; cur_bit >= 0 && remainder > 0; --cur_bit, subtractor >>= 1) {
         if (remainder < subtractor)
           continue;
         remainder -= subtractor;
-        quotient.set_bit(cur_bit);
+        quotient.set_bit(static_cast<size_t>(cur_bit));
       }
     }
     return Division{quotient, remainder};
@@ -1275,26 +1276,28 @@ rotr(T value, int rotate);
 template <typename T>
 [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T>
 rotl(T value, int rotate) {
-  constexpr unsigned N = cpp::numeric_limits<T>::digits;
+  constexpr int N = cpp::numeric_limits<T>::digits;
   rotate = rotate % N;
   if (!rotate)
     return value;
   if (rotate < 0)
     return cpp::rotr<T>(value, -rotate);
-  return (value << rotate) | (value >> (N - rotate));
+  return (value << static_cast<size_t>(rotate)) |
+         (value >> (N - static_cast<size_t>(rotate)));
 }
 
 // Specialization of cpp::rotr ('bit.h') for BigInt.
 template <typename T>
 [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T>
 rotr(T value, int rotate) {
-  constexpr unsigned N = cpp::numeric_limits<T>::digits;
+  constexpr int N = cpp::numeric_limits<T>::digits;
   rotate = rotate % N;
   if (!rotate)
     return value;
   if (rotate < 0)
     return cpp::rotl<T>(value, -rotate);
-  return (value >> rotate) | (value << (N - rotate));
+  return (value >> static_cast<size_t>(rotate)) |
+         (value << (N - static_cast<size_t>(rotate)));
 }
 
 } // namespace cpp
@@ -1311,7 +1314,7 @@ mask_trailing_ones() {
   T out; // zero initialized
   for (size_t i = 0; i <= QUOTIENT; ++i)
     out[i] = i < QUOTIENT
-                 ? -1
+                 ? cpp::numeric_limits<typename T::word_type>::max()
                  : mask_trailing_ones<typename T::word_type, REMAINDER>();
   return out;
 }
@@ -1327,7 +1330,7 @@ LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T> mask_leading_ones() {
   T out; // zero initialized
   for (size_t i = QUOTIENT; i < T::WORD_COUNT; ++i)
     out[i] = i > ...
[truncated]

@@ -296,7 +296,7 @@ LIBC_INLINE constexpr cpp::array<word, N> shift(cpp::array<word, N> array,
for (size_t index = 0; index < N; ++index) {
const word part1 = safe_get_at(index + index_offset);
const word part2 = safe_get_at(index + index_offset + 1);
word &dst = out[at(index)];
word &dst = out[static_cast<size_t>(at(index))];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

decltype(at(...)) is int, but operator[]needssize_t`

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does unsigned instead of size_t work for indexing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it works without raising a warning.

May I know what the difference would be here? AFAIK casting doesn't really change the type here (i guess) but only silences the warning? and unsigned would still be auto-promoted to size_t eventually?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general, 32-bit indexing would be enough, and unsigned is to prevent negative index.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used unsigned

@vinay-deshmukh
Copy link
Contributor Author

Pinging reviewers from: #127523, and #129771
(and who have fixed/revert the previous PR for -Wconversion) so if there's any additional bugs, it can be caught before merge

@michaelrj-google @Caslyn @frobtech @lntue

@lntue lntue self-requested a review March 7, 2025 21:46
@lntue
Copy link
Contributor

lntue commented Mar 7, 2025

Can you sync and resolve the merge conflicts? Thanks

@vinay-deshmukh vinay-deshmukh force-pushed the vinay-issue-119281-sign-conversion branch from 20ddbe9 to 2a05303 Compare March 10, 2025 04:22
@vinay-deshmukh vinay-deshmukh changed the title [libc] Add -Wsign-conversion & un-reverts -Wconversion [libc] Add -Wno-sign-conversion & re-attempt -Wconversion Mar 10, 2025
@lntue lntue merged commit 257e483 into llvm:main Mar 10, 2025
16 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 10, 2025

LLVM Buildbot has detected a new failure on builder libc-x86_64-debian-dbg-bootstrap-build running on libc-x86_64-debian while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/200/builds/5072

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[381/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.setpayloadsigf128.dir/setpayloadsigf128.cpp.o
[382/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.atanf.dir/atanf.cpp.o
[383/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_zeros_uc.dir/stdc_leading_zeros_uc.cpp.o
[384/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_zeros_us.dir/stdc_leading_zeros_us.cpp.o
[385/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.tanhf16.dir/tanhf16.cpp.o
[386/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_zeros_ui.dir/stdc_leading_zeros_ui.cpp.o
[387/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16add.dir/f16add.cpp.o
[388/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_zeros_ul.dir/stdc_leading_zeros_ul.cpp.o
[389/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_zeros_ull.dir/stdc_leading_zeros_ull.cpp.o
[390/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_uc.dir/stdc_leading_ones_uc.cpp.o
FAILED: libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_uc.dir/stdc_leading_ones_uc.cpp.o 
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/./bin/clang++ --target=x86_64-unknown-linux-gnu -DLIBC_NAMESPACE=__llvm_libc_20_0_0_git -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc -isystem /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins/libc/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -fpie -ffixed-point -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -std=gnu++17 -MD -MT libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_uc.dir/stdc_leading_ones_uc.cpp.o -MF libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_uc.dir/stdc_leading_ones_uc.cpp.o.d -o libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_uc.dir/stdc_leading_ones_uc.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/src/stdbit/stdc_leading_ones_uc.cpp
In file included from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/src/stdbit/stdc_leading_ones_uc.cpp:11:
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/src/__support/CPP/bit.h:165:30: error: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Werror,-Wimplicit-int-conversion]
  165 |   return cpp::countl_zero<T>(~value);
      |          ~~~                 ^~~~~~
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/src/stdbit/stdc_leading_ones_uc.cpp:18:37: note: in instantiation of function template specialization '__llvm_libc_20_0_0_git::cpp::countl_one<unsigned char>' requested here
   18 |   return static_cast<unsigned>(cpp::countl_one(value));
      |                                     ^
1 error generated.
[391/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_us.dir/stdc_leading_ones_us.cpp.o
FAILED: libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_us.dir/stdc_leading_ones_us.cpp.o 
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/./bin/clang++ --target=x86_64-unknown-linux-gnu -DLIBC_NAMESPACE=__llvm_libc_20_0_0_git -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc -isystem /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins/libc/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -fpie -ffixed-point -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -std=gnu++17 -MD -MT libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_us.dir/stdc_leading_ones_us.cpp.o -MF libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_us.dir/stdc_leading_ones_us.cpp.o.d -o libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_us.dir/stdc_leading_ones_us.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/src/stdbit/stdc_leading_ones_us.cpp
In file included from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/src/stdbit/stdc_leading_ones_us.cpp:11:
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/src/__support/CPP/bit.h:165:30: error: implicit conversion loses integer precision: 'int' to 'unsigned short' [-Werror,-Wimplicit-int-conversion]
  165 |   return cpp::countl_zero<T>(~value);
      |          ~~~                 ^~~~~~
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/src/stdbit/stdc_leading_ones_us.cpp:18:37: note: in instantiation of function template specialization '__llvm_libc_20_0_0_git::cpp::countl_one<unsigned short>' requested here
   18 |   return static_cast<unsigned>(cpp::countl_one(value));
      |                                     ^
1 error generated.
[392/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_ui.dir/stdc_leading_ones_ui.cpp.o
[393/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_ul.dir/stdc_leading_ones_ul.cpp.o
[394/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16addf.dir/f16addf.cpp.o
[395/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16addf128.dir/f16addf128.cpp.o
[396/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16subf.dir/f16subf.cpp.o
[397/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16sub.dir/f16sub.cpp.o
[398/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16addl.dir/f16addl.cpp.o
[399/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16divf.dir/f16divf.cpp.o
[400/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16div.dir/f16div.cpp.o
[401/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16divf128.dir/f16divf128.cpp.o
[402/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16subf128.dir/f16subf128.cpp.o
[403/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16divl.dir/f16divl.cpp.o
[404/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16subl.dir/f16subl.cpp.o
[405/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.cbrtf.dir/cbrtf.cpp.o
[406/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16fma.dir/f16fma.cpp.o
[407/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.fsqrtl.dir/fsqrtl.cpp.o
[408/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.fsqrt.dir/fsqrt.cpp.o
[409/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16sqrtf.dir/f16sqrtf.cpp.o
Step 6 (build libc) failure: build libc (failure)
...
[381/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.setpayloadsigf128.dir/setpayloadsigf128.cpp.o
[382/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.atanf.dir/atanf.cpp.o
[383/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_zeros_uc.dir/stdc_leading_zeros_uc.cpp.o
[384/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_zeros_us.dir/stdc_leading_zeros_us.cpp.o
[385/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.tanhf16.dir/tanhf16.cpp.o
[386/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_zeros_ui.dir/stdc_leading_zeros_ui.cpp.o
[387/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16add.dir/f16add.cpp.o
[388/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_zeros_ul.dir/stdc_leading_zeros_ul.cpp.o
[389/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_zeros_ull.dir/stdc_leading_zeros_ull.cpp.o
[390/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_uc.dir/stdc_leading_ones_uc.cpp.o
FAILED: libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_uc.dir/stdc_leading_ones_uc.cpp.o 
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/./bin/clang++ --target=x86_64-unknown-linux-gnu -DLIBC_NAMESPACE=__llvm_libc_20_0_0_git -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc -isystem /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins/libc/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -fpie -ffixed-point -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -std=gnu++17 -MD -MT libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_uc.dir/stdc_leading_ones_uc.cpp.o -MF libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_uc.dir/stdc_leading_ones_uc.cpp.o.d -o libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_uc.dir/stdc_leading_ones_uc.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/src/stdbit/stdc_leading_ones_uc.cpp
In file included from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/src/stdbit/stdc_leading_ones_uc.cpp:11:
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/src/__support/CPP/bit.h:165:30: error: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Werror,-Wimplicit-int-conversion]
  165 |   return cpp::countl_zero<T>(~value);
      |          ~~~                 ^~~~~~
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/src/stdbit/stdc_leading_ones_uc.cpp:18:37: note: in instantiation of function template specialization '__llvm_libc_20_0_0_git::cpp::countl_one<unsigned char>' requested here
   18 |   return static_cast<unsigned>(cpp::countl_one(value));
      |                                     ^
1 error generated.
[391/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_us.dir/stdc_leading_ones_us.cpp.o
FAILED: libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_us.dir/stdc_leading_ones_us.cpp.o 
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/./bin/clang++ --target=x86_64-unknown-linux-gnu -DLIBC_NAMESPACE=__llvm_libc_20_0_0_git -D_DEBUG -I/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc -isystem /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/build/runtimes/runtimes-bins/libc/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -g -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -fpie -ffixed-point -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -std=gnu++17 -MD -MT libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_us.dir/stdc_leading_ones_us.cpp.o -MF libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_us.dir/stdc_leading_ones_us.cpp.o.d -o libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_us.dir/stdc_leading_ones_us.cpp.o -c /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/src/stdbit/stdc_leading_ones_us.cpp
In file included from /home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/src/stdbit/stdc_leading_ones_us.cpp:11:
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/src/__support/CPP/bit.h:165:30: error: implicit conversion loses integer precision: 'int' to 'unsigned short' [-Werror,-Wimplicit-int-conversion]
  165 |   return cpp::countl_zero<T>(~value);
      |          ~~~                 ^~~~~~
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian/libc-x86_64-debian-dbg-bootstrap-build/llvm-project/libc/src/stdbit/stdc_leading_ones_us.cpp:18:37: note: in instantiation of function template specialization '__llvm_libc_20_0_0_git::cpp::countl_one<unsigned short>' requested here
   18 |   return static_cast<unsigned>(cpp::countl_one(value));
      |                                     ^
1 error generated.
[392/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_ui.dir/stdc_leading_ones_ui.cpp.o
[393/734] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_ul.dir/stdc_leading_ones_ul.cpp.o
[394/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16addf.dir/f16addf.cpp.o
[395/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16addf128.dir/f16addf128.cpp.o
[396/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16subf.dir/f16subf.cpp.o
[397/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16sub.dir/f16sub.cpp.o
[398/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16addl.dir/f16addl.cpp.o
[399/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16divf.dir/f16divf.cpp.o
[400/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16div.dir/f16div.cpp.o
[401/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16divf128.dir/f16divf128.cpp.o
[402/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16subf128.dir/f16subf128.cpp.o
[403/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16divl.dir/f16divl.cpp.o
[404/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16subl.dir/f16subl.cpp.o
[405/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.cbrtf.dir/cbrtf.cpp.o
[406/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16fma.dir/f16fma.cpp.o
[407/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.fsqrtl.dir/fsqrtl.cpp.o
[408/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.fsqrt.dir/fsqrt.cpp.o
[409/734] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16sqrtf.dir/f16sqrtf.cpp.o

@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 10, 2025

LLVM Buildbot has detected a new failure on builder premerge-monolithic-linux running on premerge-linux-1 while building libc at step 6 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/25248

Here is the relevant piece of the build log for the reference
Step 6 (build-unified-tree) failure: build (failure)
...
5.872 [1104/58/435] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.totalorderf16.dir/totalorderf16.cpp.o
5.873 [1103/58/436] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.setpayload.dir/setpayload.cpp.o
5.873 [1102/58/437] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.setpayloadsig.dir/setpayloadsig.cpp.o
5.874 [1101/58/438] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.setpayloadsigf.dir/setpayloadsigf.cpp.o
5.899 [1100/58/439] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.setpayloadsigl.dir/setpayloadsigl.cpp.o
5.899 [1099/58/440] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.setpayloadsigf16.dir/setpayloadsigf16.cpp.o
5.900 [1098/58/441] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.setpayloadsigf128.dir/setpayloadsigf128.cpp.o
5.901 [1097/58/442] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16add.dir/f16add.cpp.o
5.912 [1096/58/443] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16addf.dir/f16addf.cpp.o
5.984 [1095/58/444] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_us.dir/stdc_leading_ones_us.cpp.o
FAILED: libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_us.dir/stdc_leading_ones_us.cpp.o 
/build/buildbot/premerge-monolithic-linux/build/./bin/clang++ --target=x86_64-unknown-linux-gnu -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git -I/build/buildbot/premerge-monolithic-linux/llvm-project/libc -isystem /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/libc/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -fpie -ffixed-point -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -UNDEBUG -std=gnu++17 -MD -MT libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_us.dir/stdc_leading_ones_us.cpp.o -MF libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_us.dir/stdc_leading_ones_us.cpp.o.d -o libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_us.dir/stdc_leading_ones_us.cpp.o -c /build/buildbot/premerge-monolithic-linux/llvm-project/libc/src/stdbit/stdc_leading_ones_us.cpp
In file included from /build/buildbot/premerge-monolithic-linux/llvm-project/libc/src/stdbit/stdc_leading_ones_us.cpp:11:
/build/buildbot/premerge-monolithic-linux/llvm-project/libc/src/__support/CPP/bit.h:165:30: error: implicit conversion loses integer precision: 'int' to 'unsigned short' [-Werror,-Wimplicit-int-conversion]
  165 |   return cpp::countl_zero<T>(~value);
      |          ~~~                 ^~~~~~
/build/buildbot/premerge-monolithic-linux/llvm-project/libc/src/stdbit/stdc_leading_ones_us.cpp:18:37: note: in instantiation of function template specialization '__llvm_libc_21_0_0_git::cpp::countl_one<unsigned short>' requested here
   18 |   return static_cast<unsigned>(cpp::countl_one(value));
      |                                     ^
1 error generated.
5.984 [1095/57/445] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_ul.dir/stdc_leading_ones_ul.cpp.o
5.988 [1095/56/446] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_zeros_uc.dir/stdc_leading_zeros_uc.cpp.o
5.988 [1095/55/447] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_zeros_us.dir/stdc_leading_zeros_us.cpp.o
5.988 [1095/54/448] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_zeros_ui.dir/stdc_leading_zeros_ui.cpp.o
5.989 [1095/53/449] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_zeros_ul.dir/stdc_leading_zeros_ul.cpp.o
5.989 [1095/52/450] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_zeros_ull.dir/stdc_leading_zeros_ull.cpp.o
5.989 [1095/51/451] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_uc.dir/stdc_leading_ones_uc.cpp.o
FAILED: libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_uc.dir/stdc_leading_ones_uc.cpp.o 
/build/buildbot/premerge-monolithic-linux/build/./bin/clang++ --target=x86_64-unknown-linux-gnu -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git -I/build/buildbot/premerge-monolithic-linux/llvm-project/libc -isystem /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/libc/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -fpie -ffixed-point -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -UNDEBUG -std=gnu++17 -MD -MT libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_uc.dir/stdc_leading_ones_uc.cpp.o -MF libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_uc.dir/stdc_leading_ones_uc.cpp.o.d -o libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_uc.dir/stdc_leading_ones_uc.cpp.o -c /build/buildbot/premerge-monolithic-linux/llvm-project/libc/src/stdbit/stdc_leading_ones_uc.cpp
In file included from /build/buildbot/premerge-monolithic-linux/llvm-project/libc/src/stdbit/stdc_leading_ones_uc.cpp:11:
/build/buildbot/premerge-monolithic-linux/llvm-project/libc/src/__support/CPP/bit.h:165:30: error: implicit conversion loses integer precision: 'int' to 'unsigned char' [-Werror,-Wimplicit-int-conversion]
  165 |   return cpp::countl_zero<T>(~value);
      |          ~~~                 ^~~~~~
/build/buildbot/premerge-monolithic-linux/llvm-project/libc/src/stdbit/stdc_leading_ones_uc.cpp:18:37: note: in instantiation of function template specialization '__llvm_libc_21_0_0_git::cpp::countl_one<unsigned char>' requested here
   18 |   return static_cast<unsigned>(cpp::countl_one(value));
      |                                     ^
1 error generated.
5.989 [1095/50/452] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_leading_ones_ui.dir/stdc_leading_ones_ui.cpp.o
5.990 [1095/49/453] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.explogxf.dir/explogxf.cpp.o
6.021 [1095/48/454] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_trailing_ones_ui.dir/stdc_trailing_ones_ui.cpp.o
6.066 [1095/47/455] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.atan2.dir/atan2.cpp.o
6.095 [1095/46/456] Building CXX object libc/src/math/generic/CMakeFiles/libc.src.math.generic.f16addl.dir/f16addl.cpp.o
6.097 [1095/45/457] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_trailing_zeros_ull.dir/stdc_trailing_zeros_ull.cpp.o
6.100 [1095/44/458] Building CXX object libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_trailing_ones_us.dir/stdc_trailing_ones_us.cpp.o
FAILED: libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_trailing_ones_us.dir/stdc_trailing_ones_us.cpp.o 
/build/buildbot/premerge-monolithic-linux/build/./bin/clang++ --target=x86_64-unknown-linux-gnu -DLIBC_NAMESPACE=__llvm_libc_21_0_0_git -I/build/buildbot/premerge-monolithic-linux/llvm-project/libc -isystem /build/buildbot/premerge-monolithic-linux/build/runtimes/runtimes-bins/libc/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -DLIBC_QSORT_IMPL=LIBC_QSORT_QUICK_SORT -DLIBC_ADD_NULL_CHECKS -fpie -ffixed-point -fno-builtin -fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -Wdeprecated -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety -Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -UNDEBUG -std=gnu++17 -MD -MT libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_trailing_ones_us.dir/stdc_trailing_ones_us.cpp.o -MF libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_trailing_ones_us.dir/stdc_trailing_ones_us.cpp.o.d -o libc/src/stdbit/CMakeFiles/libc.src.stdbit.stdc_trailing_ones_us.dir/stdc_trailing_ones_us.cpp.o -c /build/buildbot/premerge-monolithic-linux/llvm-project/libc/src/stdbit/stdc_trailing_ones_us.cpp
In file included from /build/buildbot/premerge-monolithic-linux/llvm-project/libc/src/stdbit/stdc_trailing_ones_us.cpp:11:
/build/buildbot/premerge-monolithic-linux/llvm-project/libc/src/__support/CPP/bit.h:178:30: error: implicit conversion loses integer precision: 'int' to 'unsigned short' [-Werror,-Wimplicit-int-conversion]
  178 |   return cpp::countr_zero<T>(~value);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants