[PATCH] D44559: [Sema] Wrong width of result of mul operation
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 16 12:13:54 PDT 2018
aaron.ballman added a comment.
In https://reviews.llvm.org/D44559#1040435, @craig.topper wrote:
> Fair point, what is the default signedness of char?
It's decided by target architecture. ARM and PPC often use unsigned, x86 often uses signed.
> FWIW, all these warn in gcc. So they seem to be just checking purely based on the int promotion without any concern for the original size?
>
> unsigned short foo(unsigned char a) {
> return a * a;
> }
>
> signed short bar(signed char a) {
> return a * a;
> }
>
> signed short foo(signed char a) {
> return a + a;
> }
>
> unsigned short foo(unsigned char a) {
> return a + a;
> }
Yeah, this does seem to be just warning about arithmetic involving promotions, which seems rather chatty but is aligned with MISRA rule 10.6.
Repository:
rC Clang
https://reviews.llvm.org/D44559
More information about the cfe-commits
mailing list