c/1027: slightly misleading printf format warning

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


The following reply was made to PR c/1027; it has been noted by GNATS.

From: "Joseph S. Myers" <jsm28@cam.ac.uk>
To: <cwitty@newtonlabs.com>
Cc: <gcc-gnats@gcc.gnu.org>,  <gcc-bugs@gcc.gnu.org>
Subject: Re: c/1027: slightly misleading printf format warning
Date: Sun, 10 Dec 2000 11:40:57 +0000 (GMT)

 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.)
 
 -- 
 Joseph S. Myers
 jsm28@cam.ac.uk
 


More information about the Gcc-prs mailing list