On Thu, 19 Jun 2025 13:53:06 +0200 Jakub Jelinek <ja...@redhat.com> wrote:
> On Thu, Jun 19, 2025 at 01:38:06PM +0200, Rainer Orth wrote: > > --- a/gcc/cobol/genapi.cc > > +++ b/gcc/cobol/genapi.cc > > @@ -957,7 +957,7 @@ parser_compile_ecs( const std::vector<ui > > { > > SHOW_PARSE_HEADER > > char ach[64]; > > - snprintf(ach, sizeof(ach), " Size is %ld; retval is %p", > > + snprintf(ach, sizeof(ach), " Size is %zu; retval is %p", > > ecs.size(), as_voidp(retval)); > > SHOW_PARSE_TEXT(ach) > > SHOW_PARSE_END > > Please don't add %zu/%zd uses in *printf family functions, not > all hosts support that unfortunately (I think HPUX among others). > > There are HOST_SIZE_T_PRINT_UNSIGNED etc. macros in hwint.h and > fmt_size_t type the argument should be cast to (in most cases it is > actually same type as size_t, but not in all). There may still be errors, but I went to great pains to correct the message format strings over the last few weeks. For messages that use the diagnostics framework, %z is used because it's documented to work in gcc/pretty-print.cc. For messages that rely on printf(3) and friends from the C standard library ("standard" should perhaps be in quotes), I'm learning to use the hwint.h macros, even though they give "ungainly" a bad name. The things we do for portability to antique proprietary systems. It is unfortunately not obvious which is which; the function name yields little clue to which library it relies on. When I need to remind myself, I just look at the function definition. Thank you for the report, Rainer. I'll attempt to correct immediately. --jkl