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]
Other format: [Raw text]

Useless warning from gcc 3.1


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


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