Stupid GCC

Apr. 27th, 2009 02:49 pm
ewx: (geek)
[personal profile] ewx
$ cat t.c
#include <stdio.h>
int main(void) { return printf(""); }
$ gcc -Wall -c t.c
t.c: In function ‘main’:
t.c:2: warning: zero-length printf format string
$ gcc -Wall -Wno-format-zero-length -c t.c
$ gcc --version
gcc (Debian 4.3.2-1.1) 4.3.2
Copyright (C) 2008 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.

Can anyone offer a plausible reason why:

  • -Wformat-zero-length is on by default (i.e. implied by -Wformat and thus by -Wall)?
  • Why it exists at all?

FTAOD, empty format strings are perfectly legitimate (and the GCC Manual knows this).

(no subject)

Date: 2012-03-13 02:22 pm (UTC)
pm215: (Default)
From: [personal profile] pm215
...since this came up on irc again today, I looked through some older gcc releases. "zero-length format string" has been warned about since gcc 2.0 (gcc 1.42 has no format string checking at all). Whenever this came in it seems to be before the dawn of gcc's online svn repo history.

GCC bug

Date: 2012-04-04 05:04 pm (UTC)
From: [identity profile] andersk.livejournal.com
You should all add your thoughts to GCC bug 47901 “-Wall should not imply -Wformat-zero-length by default” (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47901).

February 2025

S M T W T F S
      1
2345678
9101112131415
16171819202122
232425262728 

Most Popular Tags

Expand Cut Tags

No cut tags
OSZAR »