fp_uscale.c: zero-initialize digs to silence MinGW gcc warning

MinGW gcc emits -Wmaybe-uninitialized for `digs[0]` in the
`mrb_format_float` function because it cannot prove that
`count_digits()` always returns >= 1. The code is correct
(count_digits's `d == 0` early return makes the lower bound
clear to a human reader), but gcc's flow analysis does not
follow through. Initialize `digs` to silence the false positive
across all MinGW gcc CI configurations.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-05-11 08:47:05 +09:00
parent 9bb40386ce
commit ad0ea8571f
+1 -1
View File
@@ -1204,7 +1204,7 @@ mrb_format_float(mrb_float f, char *buf, size_t buf_size, char fmt, int prec, ch
/* nonzero finite */
uint64_t d;
int p, nd, exp;
char digs[20];
char digs[20] = {0}; /* gcc -Wmaybe-uninitialized false positive: count_digits() always returns >= 1 */
if (fmt == 'S') {
/* shortest representation for to_s */