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

Peng Liu via libc-commits libc-commits at lists.llvm.org
Mon Apr 14 10:02:03 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) {
----------------
winner245 wrote:

Similarly, the `if (digits_to_write > 0)` statement on line 190 is redundant, as the outer `if` already guarantees the condition to be true. 

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


More information about the libc-commits mailing list