[cfe-commits] [Patch] -Wformat: properly handle length modifiers used with %n (Was: -Wformat: warn about using length modifiers with %n)
Ted Kremenek
kremenek at apple.com
Tue Aug 7 13:23:22 PDT 2012
On Aug 7, 2012, at 11:08 AM, Hans Wennborg <hans at chromium.org> wrote:
> On Tue, Aug 7, 2012 at 6:12 PM, Peter Cooper <peter_cooper at apple.com> wrote:
>> Hi Hans,
>>
>> This series of commits seems to be breaking the gcc test suite. Could you please investigate?
>>
>> The output we have is
>
>> gcc.dg/format/c90-printf-1.c bad argument types (test for warnings, line 200)
>> gcc.dg/format/c90-printf-1.c -DWIDE bad argument types (test for warnings, line 200)
>
> This is: printf ("%n", un);
>
> Where 'un' is 'unsigned int *'. GCC warns in -pedantic mode that it
> expects 'int *', but Clang doesn't warn since it doesn't do anything
> special with -pedantic for this kind of checks.
>
>> gcc.dg/format/c99-printf-1.c %hhn plain char (test for warnings, line 195)
>> gcc.dg/format/c99-printf-1.c %hhn unsigned char (test for warnings, line 196)
>> gcc.dg/format/c99-printf-1.c -DWIDE %hhn plain char (test for warnings, line 195)
>> gcc.dg/format/c99-printf-1.c -DWIDE %hhn unsigned char (test for warnings, line 196)
>
> Same thing here: gcc in -pedantic mode warns that it expects 'signed
> char *', not 'char *' or 'unsigned char *'. Clang again doesn't do
> anything special with -pedantic.
>
>
> The reason some of these tests passed before was that since my
> r160966, Clang would warn about any use of %n where the argument
> wasn't exactly 'int*'. This was wrong, and broke a lot of other tests
> in the suite, so the current results are a net win :)
>
> We could make -Wformat do strict argument checking with -pedantic, but
> I don't know how important that is?
Emulating GCC's behavior here adds no value other than to have compatibility with GCC.
More information about the cfe-commits
mailing list