Commit 0fe595c5
0fe595c54332Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 1 file · ~1 modified
Description
codegen: widen two emit_call buffers to silence -Wformat-truncation
gcc's -Wformat-truncation flags two worst-case formats in emit_call: a numbered
block-param name (_%d into an 8-byte buffer; up to 12 bytes for a full int)
and an ivar name (@%s into a 256-byte buffer where the base name can be up to
255 bytes, so 257 with the @ and NUL). Both are benign in practice -- the
indices are small and the names short -- but widen the buffers (16 and 258) so
the build is warning-clean. Emitted names are unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- 0fe595c54332
- Parent
- 3a1e23c985ad
src/codegen_call.cmodifiedView file
@@ -2021,7 +2021,7 @@
20212021
/* `{ _1.method }`: _1.._N bind like positional block params. */20222022
int maxn = (int)nt_int(nt, bp_node, "maximum", 0);20232023
for (int p = 0; p < maxn; p++) {2024-
char pn[8]; snprintf(pn, sizeof pn, "_%d", p + 1);2024+
char pn[16]; snprintf(pn, sizeof pn, "_%d", p + 1);20252025
emit_indent(g_pre, g_indent);20262026
buf_printf(g_pre, "lv_%s = ", rename_local(pn));20272027
if (is_exec) {@@ -3332,7 +3332,7 @@
33323332
memcpy(_abase, name, (size_t)_ablen); _abase[_ablen] = '\0';33333333
int _arc = ty_object_class(_art), _adefc = -1;33343334
if (comp_writer_in_chain(c, _arc, _abase, &_adefc)) {3335-
char _aivn[256]; snprintf(_aivn, sizeof _aivn, "@%s", _abase);3335+
char _aivn[258]; snprintf(_aivn, sizeof _aivn, "@%s", _abase);33363336
int _aiv = comp_ivar_index(&c->classes[_adefc < 0 ? _arc : _adefc], _aivn);33373337
TyKind _aivt = _aiv >= 0 ? c->classes[_adefc < 0 ? _arc : _adefc].ivar_types[_aiv] : TY_UNKNOWN;33383338
buf_puts(b, "(("); emit_expr(c, recv, b); buf_printf(b, ")->iv_%s = ", _abase);