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

Hans Wennborg hans at chromium.org
Mon Feb 20 11:25:40 PST 2012


On Mon, Feb 20, 2012 at 19:02, Ted Kremenek <kremenek at apple.com> wrote:
> Hi Hans,
>
> Thanks so much for working on this, but I'm honestly *very* concerned about the practicality of issuing all these warnings.  Real code makes assumptions on what format specifiers are available given the platform(s) they are targeting.  Unconditionally warning about non-standard stuff seems like a recipe to irritate a huge number of users.  Indeed, the format string checking now relaxes the strict interpretation of the standard in cases where it's basically always safe.  This is the behavior users expect.  I think it's also important to keep in mind the purpose of these warnings.  The purpose of these warnings is to find problems, not annoy users.
>
> For me, the better approach would be two options:
>
> (1) Warn about non-standard format strings only when it is an issue for the target platform.  This is hard to do, but this is basically what users will expect.
>
> (2) Provide an opt-in mechanism for such pedantic warnings.  For example, activating these warnings under -pedantic, or simply requiring them to pass -Wformat-nonstandard.  This will satisfy users who care about portability.
>
> I definitely think that -Wformat-nonstandard should not be on by default, and not activated by passing -Wformat.
>
> Concerning (2), there may just be an option question about warnings concerning non-portable code.  That's a wide open topic, but checking for non-standard format specifiers is really just one drop in that bucket.  It may be worth having a cohesive plan for just checking for non-portable stuff, and maybe grouping them under something like "-Wportable".
>
> Thoughts?

Keeping -Wformat-nonstandard out of -Wformat and having it in
-pedantic sounds perfectly fine to me. I expect that lines up with
what gcc does too.

Thanks,
Hans




More information about the cfe-commits mailing list