[gcc r17-2703] Use HOST_SIZE_T_PRINT_UNSIGNED in a few other spots
Jakub Jelinek via Gcc-cvs <[email protected]>
| Newsgroups | gmane.comp.gcc.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://gcc.gnu.org/g:88324596b6201e3a185430a1a73ae329fc600934 commit r17-2703-g88324596b6201e3a185430a1a73ae329fc600934 Author: Jakub Jelinek <[email protected]> Date: Sat Jul 25 21:56:48 2026 +0200 Use HOST_SIZE_T_PRINT_UNSIGNED in a few other spots On Thu, Jul 23, 2026 at 12:06 PM John David Anglin <[email protected]> wrote: > Not all hosts support the "z" format length modifier. Noticed > by inspection. That is not the only spot that does this though. I've grepped for printf.*%z and found this. 2026-07-25 Jakub Jelinek <[email protected]> gcc/ * sym-exec/sym-exec-expression.cc (symbolic_bit::print): Use HOST_SIZE_T_PRINT_UNSIGNED instead of "%zu" and add cast to fmt_size_t. * genoutput.cc (main): Likewise. gcc/cobol/ * symbols.cc (symbols_dump): Use HOST_SIZE_T_PRINT_UNSIGNED instead of "%zu" and add cast to fmt_size_t. Reviewed-by: Andrea Pinski <[email protected]> Diff: --- gcc/cobol/symbols.cc | 4 ++-- gcc/genoutput.cc | 10 ++++++---- gcc/sym-exec/sym-exec-expression.cc | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/gcc/cobol/symbols.cc b/gcc/cobol/symbols.cc index ffd68106640d..a70c4fed411c 100644 --- a/gcc/cobol/symbols.cc +++ b/gcc/cobol/symbols.cc @@ -1150,9 +1150,9 @@ symbols_dump( size_t first, bool header ) { auto p = prototype_args(L.name); unsigned long narg = p.second? p.first.size() : 0; char *base = s; - s = xasprintf("%s (%s%zu args)", base, + s = xasprintf("%s (%s" HOST_SIZE_T_PRINT_UNSIGNED " args)", base, L.prototype? "prototype, " : "", - narg); + (fmt_size_t) narg); free(base); } break; diff --git a/gcc/genoutput.cc b/gcc/genoutput.cc index 7396da659dbd..d2e2507f25e7 100644 --- a/gcc/genoutput.cc +++ b/gcc/genoutput.cc @@ -1176,8 +1176,10 @@ main (int argc, const char **argv) max_len = len; } printf ("void\nverify_reg_names_in_constraints ()\n{\n"); - printf (" static const char hregnames[%zu][%zu] = {\n", - used_reg_names.elements (), max_len + 1); + printf (" static const char hregnames[" HOST_SIZE_T_PRINT_UNSIGNED "][" + HOST_SIZE_T_PRINT_UNSIGNED "] = {\n", + (fmt_size_t) used_reg_names.elements (), + (fmt_size_t) (max_len + 1)); auto it = used_reg_names.begin (); while (it != used_reg_names.end ()) { @@ -1188,8 +1190,8 @@ main (int argc, const char **argv) printf ("\n"); } printf (" };\n"); - printf (" for (size_t i = 0; i < %zu; ++i)\n", - used_reg_names.elements ()); + printf (" for (size_t i = 0; i < " HOST_SIZE_T_PRINT_UNSIGNED + "; ++i)\n", (fmt_size_t) used_reg_names.elements ()); printf (" if (decode_reg_name (hregnames[i]) < 0)\n"); printf (" internal_error (\"invalid register %%qs used in " "constraint of machine description\", hregnames[i]);\n"); diff --git a/gcc/sym-exec/sym-exec-expression.cc b/gcc/sym-exec/sym-exec-expression.cc index 89d2ba5aba1d..6233bf2ec1b5 100644 --- a/gcc/sym-exec/sym-exec-expression.cc +++ b/gcc/sym-exec/sym-exec-expression.cc @@ -400,7 +400,8 @@ symbolic_bit::print () if (dump_file) { print_generic_expr (dump_file, m_origin, dump_flags); - fprintf (dump_file, "[%zu]", m_index); + fprintf (dump_file, "[" HOST_SIZE_T_PRINT_UNSIGNED "]", + (fmt_size_t) m_index); } }