Skip to content

Commit 0d59cfc

Browse files
[libc] fix -Wconversion in float_to_string.h (#74369)
Fixes: libc/src/__support/float_to_string.h:551:48: error: conversion from ‘long unsigned int’ to ‘int32_t’ {aka ‘int’} may change value [-Werror=conversion] 551 | const int32_t shift_amount = SHIFT_CONST + (-exponent - IDX_SIZE * idx); | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Observed in gcc fullbuilds. IDX_SIZE is a size_t (aka 'long unsigned int'), but has the value 128, so the expression is undergoing implicit promotion. Link: https://lab.llvm.org/buildbot/#/builders/250/builds/14891
1 parent d1cdcdd commit 0d59cfc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

libc/src/__support/float_to_string.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,8 @@ class FloatToString {
548548

549549
val = POW10_SPLIT_2[p];
550550
#endif
551-
const int32_t shift_amount = SHIFT_CONST + (-exponent - IDX_SIZE * idx);
551+
const int32_t shift_amount =
552+
SHIFT_CONST + (-exponent - static_cast<int>(IDX_SIZE) * idx);
552553
uint32_t digits =
553554
internal::mul_shift_mod_1e9(mantissa, val, shift_amount);
554555
return digits;

0 commit comments

Comments
 (0)