[Bug c/47901] -Wall should not imply -Wformat-zero-length by default

andersk at mit dot edu gcc-bugzilla@gcc.gnu.org
Mon Apr 23 20:22:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47901

--- Comment #5 from Anders Kaseorg <andersk at mit dot edu> 2012-04-23 20:22:20 UTC ---
I’m not sure ("%s", "") is a suitable replacement in general.  Maybe this is a
far-fetched example, but what the purpose of custom_printf is to shell-quote
all its arguments, so that custom_printf(foo, "") writes "some_command" with no
arguments but custom_printf(foo, "%s", "") writes "some_command ''" with a
single empty argument?

In any event, ("%s", "") is certainly different code with a potential runtime
cost, and it’s not fair for -Wall to complain about the more straightforward
("") unless it’s reasonably likely for that code to be hiding some class of
bugs.  Is it?

(Another real-world example from a project I help maintain:
https://github.com/barnowl/barnowl/blob/barnowl-1.8.1/keys.c#L337 )



More information about the Gcc-bugs mailing list