From ad0ea8571fdb2b74a026e1d3080b3fb3f6142350 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 11 May 2026 08:47:05 +0900 Subject: [PATCH] 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 --- src/fp_uscale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fp_uscale.c b/src/fp_uscale.c index 0b92859e9..3136a178d 100644 --- a/src/fp_uscale.c +++ b/src/fp_uscale.c @@ -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 */