https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77331

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-08-01
                 CC|                            |egallager at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #0)
> While getting the latest c-format.c changes integrated into the
> -Wformat-length pass and testing the result I noticed that GCC underlines
> different parts of the format strings than shown in the examples in the
> comment above the definition of the format_warning_va function.  The output
> shown in the comments makes sense.  The actual output not so much because
> parts of the format strings that are unrelated to the problem are underlined.
> 
> $ cat t.c && /build/gcc-trunk/gcc/xgcc -B /build/gcc-trunk/gcc -S -Wformat
> -Wformat-signedness t.c
> extern int printf (const char*, ...);
> 
> void f (const char *msg)
> {
>   printf ("hello " "%i", msg);
> 
> #define INT_FMT "%i"
> 
>   printf ("hello " INT_FMT " world", msg);
> 
> }
> t.c: In function ‘f’:
> t.c:5:11: warning: format ‘%i’ expects argument of type ‘int’, but argument
> 2 has type ‘const char *’ [-Wformat=]
>    printf ("hello " "%i", msg);
>            ^~~~~~~~
> t.c:5:22: note: format string is defined here
>    printf ("hello " "%i", msg);
>                      ~^
>                      %s
> t.c:9:11: warning: format ‘%i’ expects argument of type ‘int’, but argument
> 2 has type ‘const char *’ [-Wformat=]
>    printf ("hello " INT_FMT " world", msg);
>            ^~~~~~~~
> t.c:7:19: note: format string is defined here
>  #define INT_FMT "%i"
>                   ~^
>                   %s

Confirmed.

Reply via email to