[PATCH] D52137: Added warning for unary minus used with unsigned type

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 15 11:23:05 PDT 2018


lebedev.ri added a comment.

In https://reviews.llvm.org/D52137#1236011, @xbolva00 wrote:

> /home/xbolva00/LLVM/build/lib/clang/8.0.0/include/bmiintrin.h:312:16: error: unary minus operator applied to type 'unsigned long long', result value is still unsigned
>
>   return __X & -__X;
>   
>
> @RKSimon what do you think? valid? Can we fix that header to return __X & -(int)__X;?
>  @craig.topper


That is not correct transformation as far as i can see.
https://godbolt.org/z/qbQDSq
https://rise4fun.com/Alive/wsPn


https://reviews.llvm.org/D52137





More information about the cfe-commits mailing list