[llvm] r224195 - Silencing a -Wsign-compare warning; NFC.

Chandler Carruth chandlerc at google.com
Sun Dec 14 14:32:17 PST 2014


On Sat, Dec 13, 2014 at 8:55 AM, Aaron Ballman <aaron at aaronballman.com>
wrote:
>
>        uint64_t Shift = 64 - EmissionSize * 8;
> -      assert(Shift < std::numeric_limits<unsigned long long>::digits &&
> +      assert(Shift < static_cast<unsigned>(
> +                         std::numeric_limits<unsigned long long>::digits)
> &&
>

The LHS is a 64-bit number here, it seems odd to cast to a (potentially)
32-bit number.

Why couldn't all of these be signed integers, and we get UBSan failures if
the math is wrong? I really dislike this use of unsigned here, and I feel
that numeric_limits got this right -- these are small "numbers" and "int"
seems like a really nice type for them. =]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141214/9ca2e4a9/attachment.html>


More information about the llvm-commits mailing list