Stupid GCC
Apr. 27th, 2009 02:49 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
$ 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: 2009-04-27 02:13 pm (UTC)(I've often thought that a lot of compiler warnings need a special case "unless it was generated by a macro", because the sorts of things that indicate a probable user error when they appear in handwritten code are often very similar to the sorts of things that are perfectly sensible preprocessor output.)
(no subject)
Date: 2009-04-27 02:24 pm (UTC)(no subject)
Date: 2009-04-27 02:33 pm (UTC)__I_meant_to_do_this(arbitrary C code)
sort of construction which would work equally well against any warning, with which you could then liberally pepper your complicated macro setups.(In a really ideal world it would also work equally well in any compiler, but the boat is well and truly missed on that one.)