[PATCH] D42933: [Sema] Avoid -Wformat warning for NSInteger/NSUInteger 'int' values with %zu/%zi long specifiers
JF Bastien via cfe-commits
cfe-commits at lists.llvm.org
Wed May 9 13:36:58 PDT 2018
> On May 9, 2018, at 1:25 PM, Shoaib Meenai via Phabricator <reviews at reviews.llvm.org> wrote:
>
> smeenai added a comment.
>
> Yeah, I think we all agree now that a portability warning isn't really tractable. Note that even for the warnings that motivated this diff, they should have only fired if `size_t` and NSInteger had separate types, so it wasn't a portability warning in that sense to begin with (as in, it would only warn if there was a mismatch for your current target, not if there was a potential mismatch for any target).
>
> We still have two options:
>
> 1. Special-case NSInteger/NSUInteger on Apple platforms so that they can always be printed using `%z` without any issues.
> 2. Relax the format specifier warnings (either under a new warning option, e.g. `-Wformat-relaxed`, or by relaxing `-Wformat` itself and adding something like `-Wformat-pedantic`) so that you don't warn when the specifier and the actual type have the same size and alignment, even when the actual type is different (which would also cover the case in 1).
>
> I'm personally in favor of 2, and I can start a discussion on cfe-dev if you think we should try to achieve a broader consensus. Whichever option we went with, we would also have to ensure that the optimizer didn't do anything bad (as @aaron.ballman pointed out), both now and in the future
2 sounds better overall. However I don’t like a relaxed flag because it’s weird when you have relaxed/normal/pedantic. How do they mix? What if I want format warnings, but not “portability” ones. I think we either want to move this to pedantic and (as you propose) only warm on -Wformat if size or alignment don’t match. We can also have a separate -Wformat-portability warning where we try (and fail) to be helpful.
Please do start a thread on cfe-dev, much appreciated!
> Repository:
> rC Clang
>
> https://reviews.llvm.org/D42933
>
>
>
More information about the cfe-commits
mailing list