This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Useless warning from gcc 3.1
- From: Martin Stromberg <eplmst at epl dot ericsson dot se>
- To: gcc-bugs at gcc dot gnu dot org
- Cc: djgpp-workers at delorie dot com (DJGPP-WORKERS)
- Date: Mon, 27 May 2002 15:15:17 +0200 (MET DST)
- Subject: 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