Commit 32524b79
32524b7933d0Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
analyze: widen numbered-param name buffers to silence -Wformat-truncation
infer_block_params formats numbered block-param names (_1, _2, ...) into an
8-byte buffer with snprintf(nm, sizeof nm, "_%d", k). gcc's -Wformat-truncation
flags the worst case (_ + up to 10 int digits + NUL = 12 bytes) even though k
is always a small numbered-parameter index. Widen the two buffers to 16 bytes;
behavior is unchanged (the emitted names are identical).
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 32524b7933d0
- Parent
- c179e9a38c26
src/analyze_pass.cmodifiedView file
@@ -2039,7 +2039,7 @@
20392039
/* `{ _1.method }` : _1.._N all receive self (the receiver). */20402040
int maxn = (int)nt_int(nt, pn, "maximum", 0);20412041
for (int k = 1; k <= maxn; k++) {2042-
char nm[8]; snprintf(nm, sizeof nm, "_%d", k);2042+
char nm[16]; snprintf(nm, sizeof nm, "_%d", k);20432043
LocalVar *lv = scope_local_intern(bs, nm); lv->is_block_param = 1;20442044
if (lv->type != rt) { lv->type = rt; changed = 1; }20452045
}@@ -2091,7 +2091,7 @@
20912091
call-site arg types. */20922092
int maxn = (int)nt_int(nt, pn, "maximum", 0);20932093
for (int k = 0; k < maxn && k < iac; k++) {2094-
char npn[8]; snprintf(npn, sizeof npn, "_%d", k + 1);2094+
char npn[16]; snprintf(npn, sizeof npn, "_%d", k + 1);20952095
TyKind at = infer_type(c, iav[k]);20962096
LocalVar *lv = scope_local_intern(bs, npn); lv->is_block_param = 1;20972097
if (at != TY_UNKNOWN && lv->type != at) { lv->type = at; changed = 1; }