http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44513
Nicola Pero <nicola at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |nicola at gcc dot gnu.org
--- Comment #1 from Nicola Pero <nicola at gcc dot gnu.org> 2011-01-17 23:48:16
UTC ---
I tested GCC 4.6.0, and it seems to have been modified to match what you
want:
cat -n test.c
1 #include "stdio.h"
2
3 void
4 foo (int i)
5 {
6 printf ("%d%d", i);
7 }
gcc test.c -c -Wall
test.c: In function ‘foo’:
test.c:6:3: warning: format ‘%d’ expects a matching ‘int’ argument [-Wformat]
I personally preferred GCC's original error message; when you have lots of
arguments, the new system will generate lots of error messages, all of them
technically correct, but providing a confusing picture. Eg,
void foo (int i, float f, int j, float c)
{
printf ("%d%f%d%f", f, j, c);
}
(where the missing argument is the first one) will generate 4 error messages
now:
test.c: In function ‘foo’:
test.c:5:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 2
has type ‘double’ [-Wformat]
test.c:5:3: warning: format ‘%f’ expects argument of type ‘double’, but
argument 3 has type ‘int’ [-Wformat]
test.c:5:3: warning: format ‘%d’ expects argument of type ‘int’, but argument 4
has type ‘double’ [-Wformat]
test.c:5:3: warning: format ‘%f’ expects a matching ‘double’ argument
[-Wformat]
In this context, I would prefer the traditional GCC error message ("too few
arguments"), which is a simple, clear summary of the problem.
Thanks