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

Ted Kremenek kremenek at apple.com
Mon Feb 20 13:27:47 PST 2012


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

> On Mon, Feb 20, 2012 at 11:02:25AM -0800, Ted Kremenek wrote:
>> (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.
> 
> IMO most of the format extensions are of questionable value (%m),
> outdated historic extensions (q modifier) or just plainly unportable (S
> modifier).

I hear you, but some extensions continue to be advocated and used.  For example, consider this document:

  https://developer.apple.com/library/mac/#documentation/CoreFoundation/Conceptual/CFStrings/formatSpecifiers.html

Here 'q' is plainly advocated as a method for printing out 64-bit integers.  This contrasts with Mac OS X's man page for printf, which clearly points to the length modifier 'q' as being deprecated.  Maybe the documentation just needs to be updated, or maybe 'q' should just continue to make sense for Objective-C strings, but there's a fair amount of subjectiveness here and it is confusing for developers.

I'd be a lot more happy with this discussion if we took the patch with the proposed change, ran it over a ton of code, and observed the warning fallout.  If it's insignificant or reasonable, I think that's a reasonable place to start a conversation about having such warnings on by default.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120220/812f99e7/attachment.html>


More information about the cfe-commits mailing list