mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
+1
-1
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user