[PATCH] D78508: [Clang] Allow long as size_t printf argument on 32-bit Windows platforms.

Jacek Caban via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 15 13:03:53 PDT 2020


jacek added a comment.

I don't mind dropping the patch, we can mitigate the problem in Wine. My understanding is that we could use "pedantic" logic similar to NSInteger in checkFormatExpr, please let me know if you'd like something like that.

I still think that using casts in such cases is not the right pattern. For an example, if developer knows that SIZE_T is a type that will always be compatible with %z, the code:
printf("%zd", size);
is not wrong. Proposed casts would change all such cases to:
printf("%zd", (size_t)size);
Now imagine that I made a mistake and changed type of size to a type of different size. In the first variant, clang will issue a warning. In the second case, the cast will hide the warning, but I'm probably interested in changing the format instead.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78508/new/

https://reviews.llvm.org/D78508





More information about the cfe-commits mailing list