[clang] [Clang] Force expressions with UO_Not to not be non-negative (PR #126846)
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 10 13:49:42 PDT 2025
ahatanak wrote:
> unsigned int foo(unsigned char x)
> {
> return ~(1<<x); // warning: implicit conversion loses integer precision: 'int' to 'unsigned int'
> }
> ```
Could you help me understand why clang is emitting the warning?
Isn't it semantically equivalent to the following code?
```
unsigned int foo(unsigned char x)
{
int i = ~(1<<x); // no -Wimplicit-int-conversion warning.
return I; // no -Wimplicit-int-conversion warning.
}
```
https://github.com/llvm/llvm-project/pull/126846
More information about the cfe-commits
mailing list