c/1027: slightly misleading printf format warning

Gabriel Dos Reis gdr@codesourcery.com
Sun Dec 10 03:57:00 GMT 2000


"Joseph S. Myers" <jsm28@cam.ac.uk> writes:

| 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
| precise.
| 
| 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.)

I've already put in the necessary machinery for so doing in
diagnostics.*.  What remains to be done is to replace error_with_decl()
and warning_with_decl() to error() and warning() (maybe error_at())
with use of those specifiers.  That was planed but I didn't get the
chance to finish the work.  Already on my TODO list but I would love
to assist any taker. 

-- Gaby


More information about the Gcc-bugs mailing list