This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: c/1017: -Wmissing-format-attribute gives too many warnings
- To: <aj at suse dot de>
- Subject: Re: c/1017: -Wmissing-format-attribute gives too many warnings
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Fri, 8 Dec 2000 19:07:22 +0000 (GMT)
- cc: <gcc-gnats at gcc dot gnu dot org>, <gcc-bugs at gcc dot gnu dot org>
On Fri, 8 Dec 2000 aj@suse.de wrote:
> Compile this small program with -Wmissing-format-attribute -Wformat:
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> extern void dbg_log (const char *str, ...)
> __attribute__ ((__format__ (__printf__, 1, 0)));
>
> int
> test (void)
> {
> dbg_log ("%s:", "Test");
>
> return 0;
> }
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is as documented - the attribute of dbg_log suggests that it is
vprintf-like - but since the function test plainly can't have a format
attribute since it lacks of suitable parameter, I'll add a check that the
possible candidate for a format attribute has at least one parameter to
which the attribute could be attached.
(If this example came from real code, why can't dbg_log have a non-zero
first_arg_num specified, and is this something that could reasonably be
addressed as part of extensible format checking?)
--
Joseph S. Myers
jsm28@cam.ac.uk