[cfe-commits] [Patch] -Wformat: warn about using length modifiers with %n

Matt Beaumont-Gay matthewbg at google.com
Thu Aug 2 09:53:03 PDT 2012


LGTM, though one comment:

--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -90,6 +90,8 @@ void check_writeback_specifier()
   char *b;
   printf("%n", b); // expected-warning{{format specifies type 'int *'
but the argument has type 'char *'}}
   printf("%n", &x); // no-warning
+
+  printf("%n", &x); // no-warning

Is this supposed to be a no-warning test for scanf?

On Thu, Aug 2, 2012 at 2:10 AM, Hans Wennborg <hans at chromium.org> wrote:
> On Wed, Aug 1, 2012 at 2:43 PM, Hans Wennborg <hans at chromium.org> wrote:
>> Hi all,
>>
>> As far as I know, using any length modifier with %n is undefined
>> behavior. For some reason, Clang doesn't think so, but that's probably
>> unintentional? The attached patch makes Clang warn about it.
>>
>> Please take a look.
>
> Ping?
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list