[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:02 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:
The outer `if` condition guarantees that `buffered_digits - digits_to_write >= 0`. So underflow does not occur here. However, the proposed change enhances clarity and readability.
https://github.com/llvm/llvm-project/pull/135595
More information about the libc-commits
mailing list