This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/64955] New: RFE: have -Wformat suggest the correct format string to use
- From: "dmalcolm at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 05 Feb 2015 21:33:29 +0000
- Subject: [Bug c++/64955] New: RFE: have -Wformat suggest the correct format string to use
- Auto-submitted: auto-generated
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 ;) )