[libc-commits] [libc] [libc] Fix incorrect unsigned comparison (PR #135595)

Wu Yingcong via libc-commits libc-commits at lists.llvm.org
Mon Apr 14 22:04:13 PDT 2025


================
@@ -192,7 +192,7 @@ template <WriteMode write_mode> class FloatWriter {
         RET_IF_RESULT_NEGATIVE(writer->write({block_buffer, digits_to_write}));
       }
       RET_IF_RESULT_NEGATIVE(writer->write(DECIMAL_POINT));
-      if (buffered_digits - digits_to_write > 0) {
+      if (buffered_digits > digits_to_write) {
----------------
yingcong-wu wrote:

I agree that the `if` in line 190 is redundant and that is quite clear, but I don't think it is straightforward that the outer `if` also guarantees `buffered_digits - digits_to_write >= 0`, not to me anyway. I will remove the redundant `if` in line 190.

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


More information about the libc-commits mailing list