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

Joerg Sonnenberger joerg at britannica.bec.de
Tue Feb 21 12:58:40 PST 2012


On Tue, Feb 21, 2012 at 12:27:16PM -0800, Ted Kremenek wrote:
> 
> On Feb 21, 2012, at 12:23 PM, Joerg Sonnenberger <joerg at britannica.bec.de> wrote:
> 
> >>> Do we really silently accept them?  Until very recently (a month ago?), we
> >>> emitted:
> >>> 
> >>> t.c:4:12: warning: length modifier 'L' results in undefined behavior or no
> >>>       effect with 'i' conversion specifier [-Wformat]
> >>>   printf("%Li", (long long) 2);
> >>>           ~^~
> >>> 1 warning generated.
> >>> 
> >>> 
> >>> Now I see that TOT doesn't warn here.  Is this accepted somewhere?  I see no
> >>> test cases in clang/test that shows we should accept this.  Was this an
> >>> intentional change, or a regression?
> >> 
> >> r148859 made them accepted about a month ago. Looks intentional to me :)
> > 
> > Which brings up the question, where is that documented? At least the
> > Linux documentation is silent on this being valid.
> 
> 
> According to PR 9466, this is a general GNU extension:
> 
> http://www.gnu.org/software/libc/manual/html_node/Integer-Conversions.html

The printf(3) man page doesn't list it in the normal section and
contains:

       Linux libc5 knows about the five C  standard  flags  and  the  '
       flag, locale,  "%m$" and "*m$".  It knows about the length modifiers
       h, l, L, Z, and q, but accepts L and q both for long double and for
       long  long int  (this is a bug).

under CONFORMING TO. That sounds a lot like the consensus in the BSD
camp for q -- it exists and can't be killed for historic reasons, but it
should strongly be discouraged.

Joerg



More information about the cfe-commits mailing list