delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2002/05/27/09:36:30

From: Martin Stromberg <eplmst AT epl DOT ericsson DOT se>
Message-Id: <200205271315.PAA09349@lws256.lu.erisoft.se>
Subject: Useless warning from gcc 3.1
To: gcc-bugs AT gcc DOT gnu DOT org
Date: Mon, 27 May 2002 15:15:17 +0200 (MET DST)
Cc: djgpp-workers AT delorie DOT com (DJGPP-WORKERS)
X-Mailer: ELM [version 2.5 PL3]
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com

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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019