[llvm] r228027 - Fixed signed/unsigned comparison warning.

Chad Rosier mcrosier at codeaurora.org
Tue Feb 3 13:30:14 PST 2015

> On Tue, Feb 3, 2015 at 1:10 PM, Chad Rosier <mcrosier at codeaurora.org>
> wrote:
>> Hi Simon,
>> MVT::getVectorNumElements() has an 'unsigned' return type.
>> Would it make more sense to change NumElements to unsigned and fix the
>> induction variables for those loops that compare NumElements, rather
>> than
>> using a cast in the assert?
> I strongly prefer not to.
> We are often doing subtraction and other things, and in fact using them
> with values which can be -1. Using unsigned anywhere in this code is just
> wrong.
> The nice thing about casting to an int is that UBSan can throw an error if
> it is out-of-range.

Good to know!  Thanks, Chandler.

More information about the llvm-commits mailing list