[cfe-commits] [Patch] -Wformat: properly handle length modifiers used with %n (Was: -Wformat: warn about using length modifiers with %n)
Hans Wennborg
hans at chromium.org
Tue Aug 7 11:08:12 PDT 2012
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?
Thanks,
Hans
More information about the cfe-commits
mailing list