diff --git a/src/hb-private.hh b/src/hb-private.hh index e97aab6c5..2709c0efe 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -848,7 +848,9 @@ hb_in_range (T u, T lo, T hi) * to generate a warning than unused variables. */ ASSERT_STATIC (sizeof (hb_assert_unsigned_t) >= 0); - return (u - lo) <= (hi - lo); + /* The casts below are important as if T is smaller than int, + * the subtract results will become a signed int! */ + return (T)(u - lo) <= (T)(hi - lo); } template static inline bool