This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: c/1017: -Wmissing-format-attribute gives too many warnings


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]