[libc-commits] [libc] [libc][__support] Fix -Wimplicit-int-conversion warning (PR #132839)
Paul Kirth via libc-commits
libc-commits at lists.llvm.org
Mon Mar 24 15:18:43 PDT 2025
https://github.com/ilovepi created https://github.com/llvm/llvm-project/pull/132839
Newer versions of clang now warn about these, so use explicit
conversion instead.
>From cf09a31e383208a9eaed462ec2935f013fe6321f Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Mon, 24 Mar 2025 15:16:00 -0700
Subject: [PATCH] [libc][__support] Fix -Wimplicit-int-conversion warning
Newer versions of clang now warn about these, so use explicit
conversion instead.
---
libc/src/__support/float_to_string.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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