This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/64955] New: RFE: have -Wformat suggest the correct format string to use


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

            Bug ID: 64955
           Summary: RFE: have -Wformat suggest the correct format string
                    to use
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org

Currently, -Wformat tells me that I got something wrong but doesn't tell we
what the correct format string is:

$ ./xgcc --version
xgcc (GCC) 5.0.0 20150204 (experimental)
(etc)

$ cat test.c
#include <stdio.h>

void test (long long ll)
{
  printf ("%i\n", ll);
}


$ ./xgcc -c -B. test.c -Wformat
test.c: In function âtestâ:
test.c:5:11: warning: format â%iâ expects argument of type âintâ, but argument
2 has type âlong long intâ [-Wformat=]
   printf ("%i\n", ll);
           ^

It would be helpful if gcc could emit something like:
test.c:5:11: note: âprintfâ expects format string â%lliâ for type âlong long
intâ.

and maybe, if it can't be handled:
test.c:5:11: note: âprintfâ does not have a format string for handling type
âstruct fooâ.

as an additional clarifying note after the warning/error

(Bonus points: have GCC generate a patch to fix it ;) )

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]