This is the mail archive of the gcc-patches@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: warning for -Wformat and non-literal-string format



Oops.  That pesky glibc again...  :-)

The more I think about it -- and the more I run the compiler on the
code at work :-) -- the more I think that checking for the current
function also having a format attribute is the right way to go.
I'll work on it...  Once that's done, it should trigger less often
(in cases like this, at least, where gcc-specific attributes may be
allowed), and then we can look at whether another option really is
needed.

> >> Unfortunately, it also complains on variadic routines that themselves
> >> accept formats and parameters, and call vfprintf or vsyslog or
> >> whatever.  If such calling functions have format attribute
> >> declarations too, it may be possible to refine the check somewhat.
> >> But I'm just going to check those cases by hand, for now. :-)

Andreas Jaeger <aj@suse.de> writes:
> Bootstrapping egcs I got a number of:
> In file included from /usr/include/stdio.h:631,
>                  from ../../cvs/gcc/gcc/system.h:33,
>                  from insn-emit.c:5:
> /usr/include/bits/stdio.h: In function `vprintf':
> /usr/include/bits/stdio.h:35: warning: format not a string literal, argument types not checked
> 
> The warnings come from this piece of code in <bits/stdio.h> (from
> glibc 2.1.2):
> 
> /* Write formatted output to stdout from argument list ARG.  */
> __STDIO_INLINE int
> vprintf (__const char *__restrict __fmt, _G_va_list __arg) __THROW
> {
>   return vfprintf (stdout, __fmt, __arg);
> }
> 
> Is there a way to stop these warnings?


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