[PATCH] D132266: [Clang][SemaChecking] move %hh and %h -Wformat warnings to -Wformat-pedantic

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 22 07:21:24 PDT 2022


aaron.ballman added a comment.

In D132266#3739567 <https://reviews.llvm.org/D132266#3739567>, @inclyc wrote:

> N2562.pdf:
>
>> Modify 7.21.6.2p12:
>> ...
>>  Unless a length modifier is specified, t~~T~~he corresponding argument shall be a pointer to int ~~signed integer~~.
>
> Does this clarification statement mean that `hhd` should not be considered to correspond to `int`, but a `signed char`?

Correct.

> If so, could this exactly imply that we have unmatched argument type? (i.e. `int` <--x--> `hhd` (signed char) )

Here's how that's intended to be read:

  int i;
  signed char sc;
  unsigned char uc;
  char c;
  
  scanf("%hhd, %hhd, %hhd, %hhd", &i, &sc, &uc, &c);

The first format specifier has a type mismatch: expected `signed char *` or `unsigned char *`, got `int *`.
The second format specifier is correct: expected `signed char *` or `unsigned char *`, got `signed char *`.
The third format specifier is correct: expected `signed char *` or `unsigned char *`, got `unsigned char *`.
The fourth format specifier is questionable (and I'll file an NB comment to clarify this) but I think intended to be correct: expected `signed char *` or `unsigned char *`, got `char *`. Pedantically, this is incorrect per 6.2.5 making `char` special.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132266



More information about the cfe-commits mailing list