[cfe-commits] [Patch] Warn about non-standard format strings (PR12017)

Ted Kremenek kremenek at apple.com
Mon Feb 20 11:22:18 PST 2012


On Feb 20, 2012, at 11:04 AM, Joerg Sonnenberger <joerg at britannica.bec.de> wrote:

> On Mon, Feb 20, 2012 at 06:31:53PM +0000, Hans Wennborg wrote:
>> I'm a little bit confused about the status of some of these. For
>> example, should 'C' and 'S' be considered GNU extensions, and
>> therefore allowable when using -std=gnu99?
> 
> In my opinion: no. -std=gnu99 specifies C99 with GNU compiler
> extensions. It doesn't mean anything about the run time implementation.
> As such, all the non-standard flags should go into a -Wformat-extensions
> category and it should be enabled by default with -Wformat.

I would expect most users would be very unhappy to see these warnings even when compiling with -std=gnu99.  I think it is reasonable to activate them (or a subset) for -std=c99, as that essentially ties in with the portability argument I said in my other email.

We should aim to do the right thing for users.  In my experience, most users are not going to want to see these pedantic warnings unless they add value.

I agree that ultimately this comes down to what the runtime supports, but not knowing those details doesn't give us liberty to emit a bunch of new warnings just because we don't have enough information to make a good decision about whether to emit a warning or not.  A reasonable heuristic is that if  (a) adding a warning adds value for most users and (b) we can do that warning with a reasonable amount of noise then we should aggressively pursue turning that warning on the regular usage scenarios (e.g., passing -Wformat or -Wall).  I'm not certain if either (a) or (b) are satisfied here, which is why I think this should be an opt-in warning until we know how to do this better.



More information about the cfe-commits mailing list