[PATCH] D132568: [clang][Sema] check default argument promotions for printf

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 25 09:37:57 PDT 2022


aaron.ballman added inline comments.


================
Comment at: clang/lib/AST/FormatString.cpp:367
+        case BuiltinType::Char_U:
+        case BuiltinType::Bool:
+          return Match;
----------------
inclyc wrote:
> aaron.ballman wrote:
> > Isn't this a match promotion as well? e.g. `printf("%hhd", (_Bool)0);` where the `_Bool` is promoted to `int` but then cast back down to a char type (which seems rather unlikely to be a type confusion issue).
> Hmm? `_Bool` just matches `AnyCharTy` perfectly. `MatchPromotion` means the types having **different** length and they can be considered as "partially matched" because of promotions). 
> 
> Isn't `_Bool`  and `AnyChar`  here just have the same length?
> Hmm? _Bool just matches AnyCharTy perfectly. MatchPromotion means the types having different length and they can be considered as "partially matched" because of promotions).
>
> Isn't _Bool and AnyChar here just have the same length?

`_Bool` is not a character type, so it doesn't match `AnyCharTy` perfectly. The size can be the same but they're still different types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132568



More information about the cfe-commits mailing list