[libc-commits] [libc] [libc][__support] Fix -Wimplicit-int-conversion warning (PR #132839)
via libc-commits
libc-commits at lists.llvm.org
Mon Mar 24 15:19:41 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Paul Kirth (ilovepi)
<details>
<summary>Changes</summary>
Newer versions of clang now warn about these, so use explicit
conversion instead.
---
Full diff: https://github.com/llvm/llvm-project/pull/132839.diff
1 Files Affected:
- (modified) libc/src/__support/float_to_string.h (+3-3)
``````````diff
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
}
};
``````````
</details>
https://github.com/llvm/llvm-project/pull/132839
More information about the libc-commits
mailing list