Useless warning from gcc 3.1

Martin Stromberg eplmst@epl.ericsson.se
Mon May 27 06:15:00 GMT 2002


Consider this program (h.c):

#include <stdio.h>

int main(void)
{
  char s[10];
  
  printf("");
  sprintf(s, "");

  return 0;
}

Platform is DJGPP and gcc --version says:
gcc.exe (GCC) 3.1
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gcc -Wall h.c -O2 says:

h.c: In function `main':
h.c:7: warning: zero-length format string
h.c:8: warning: zero-length format string


Why is a "" format string worthy of a warning?

There are perfectly legitimate uses for emtpy format strings,
e. g. automatically generated ones.

Can anyone give me a valid good reason why a "" format string _should_
generate a warning?


Right,

						MartinS



More information about the Gcc-bugs mailing list