[libc-commits] [libc] [libc][NFC] fix int warnings in float conversion (PR #74379)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Mon Dec 4 14:40:17 PST 2023


================
@@ -864,7 +867,7 @@ LIBC_INLINE int convert_float_dec_auto_typed(Writer *writer,
              (cur_last_digit == 9 || cur_last_digit == 0)) {
         // If the next digit is not the same as the previous one, then there are
         // no more contiguous trailing digits.
-        if ((copy_of_digits % 10) != cur_last_digit) {
+        if (static_cast<int>(copy_of_digits % 10) != cur_last_digit) {
----------------
nickdesaulniers wrote:

/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/stdio/printf_core/float_dec_converter.h:867:35: error: comparison of integer expressions of different signedness: ‘__llvm_libc_18_0_0_git::BlockInt’ {aka ‘unsigned int’} and ‘int’ [-Werror=sign-compare]


if BlockInt is unsigned, perhaps copy_of_digits should also be unsigned, and modulo 10U?

https://github.com/llvm/llvm-project/pull/74379


More information about the libc-commits mailing list