[libc-commits] [libc] 0aa4c35 - [libc][__support] Fix -Wimplicit-int-conversion warning (#132839)
via libc-commits
libc-commits at lists.llvm.org
Mon Mar 24 16:47:11 PDT 2025
Author: Paul Kirth
Date: 2025-03-24T16:47:07-07:00
New Revision: 0aa4c35beb1f4f8028d79b9ce225a338db0bf9a2
URL: https://github.com/llvm/llvm-project/commit/0aa4c35beb1f4f8028d79b9ce225a338db0bf9a2
DIFF: https://github.com/llvm/llvm-project/commit/0aa4c35beb1f4f8028d79b9ce225a338db0bf9a2.diff
LOG: [libc][__support] Fix -Wimplicit-int-conversion warning (#132839)
Newer versions of clang now warn about these, so use explicit
conversion instead.
Added:
Modified:
libc/src/__support/float_to_string.h
Removed:
################################################################################
diff --git a/libc/src/__support/float_to_string.h b/libc/src/__support/float_to_string.h
index 4b03eaf4d02f2..d88bf844b15af 100644
--- a/libc/src/__support/float_to_string.h
+++ b/libc/src/__support/float_to_string.h
@@ -491,7 +491,7 @@ class FloatToString {
LIBC_INLINE constexpr BlockInt get_negative_block(int block_index) {
if (exponent < 0) {
- const int32_t idx = -exponent / IDX_SIZE;
+ const int32_t idx = -exponent / static_cast<int32_t>(IDX_SIZE);
UInt<MID_INT_SIZE> val;
@@ -579,7 +579,7 @@ class FloatToString {
return num_requested_digits > -exponent;
#else
- const int32_t idx = -exponent / IDX_SIZE;
+ const int32_t idx = -exponent / static_cast<int32_t>(IDX_SIZE);
const size_t p =
POW10_OFFSET_2[idx] + negative_block_index - MIN_BLOCK_2[idx];
// If the remaining digits are all 0, then this is the lowest block.
@@ -601,7 +601,7 @@ class FloatToString {
}
return 0;
#else
- return MIN_BLOCK_2[-exponent / IDX_SIZE];
+ return MIN_BLOCK_2[-exponent / static_cast<int32_t>(IDX_SIZE)];
#endif
}
};
More information about the libc-commits
mailing list