YutongZhuu 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.
> }
> ```

The conversion isn't implicit in the latter case.

https://github.com/llvm/llvm-project/pull/126846
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to