manual claims vsprintf args checked

Martin v. Loewis martin@mira.isdn.cs.tu-berlin.de
Tue Aug 31 22:45:00 GMT 1999


>          The compiler always
>      checks formats for the ANSI library functions `printf', `fprintf',
>      `sprintf', `scanf', `fscanf', `sscanf', `vprintf', `vfprintf' and
>      `vsprintf' whenever such warnings are requested (using
>      `-Wformat') ....
> 
> But does it, could it, really check vprintf, vfprintf and vsprintf?

It can't check the argument, for obvious
reasons. c-common.c:record_function_format has the funny (?) comment

   FIRST_ARG_NUM is the number of the first actual argument to check
   against the format string, or zero if no checking is not be done
   (e.g. for varargs such as vfprintf).

(perhaps I don't understand what a double negative in the English
language does not mean :-)

It still can check the format itself, and does in cases like

#include <stdio.h>
#include <stdarg.h>

void foo(int i,...)
{
  va_list ap;
  va_start(ap, i);
  vprintf("%3  \n",ap);
  va_end(ap);
}

gcc 2.95 gives me

a.c: In function `foo':
a.c:8: warning: unknown conversion type character ` ' in format

Hope this helps,
Martin



More information about the Gcc-bugs mailing list