c/1027: slightly misleading printf format warning

Joseph S. Myers jsm28@cam.ac.uk
Sun Dec 10 03:41:00 GMT 2000

On 10 Dec 2000 cwitty@newtonlabs.com wrote:

> When you compile the following code with -c -O -Wall -g,
> the warning messages include:
> 7: warning: char format, double arg (arg 2)
> for the line
> printf("%s", &d);
> I find this warning misleading; I would prefer:
> warning: char* format, double* arg (arg 2)

The problem is that the code for printing type names when format checking
tries to be too clever about working out the names to use and deciding
that types are the same from their names when it had already decided that
they were different types.  This leads to various other oddities with
messages referring to "different type arg" when they could be more

The C++ front end includes general support for producing a name for an
arbitrary type in diagnostics with the %T format specifier in cp_error,
cp_pedwarn etc..  What's needed to fix this problem properly is for the C
front end to get something along the lines of what the C++ front end has
for formatting types; then the actual argument type could be formatted
with %T.  (Adding these capabilities to the C front end could probably
also lead to better diagnostics in various other places.)

Joseph S. Myers

More information about the Gcc-bugs mailing list