Add back wider cast to IntType

My local clang12 is fine, but many bots are not:

../src/hb-ot-cff1-table.hh: In instantiation of ‘bool CFF::Charset1_2<TYPE>::sanitize(hb_sanitize_context_t*, unsigned int) const [with TYPE = OT::IntType<unsigned char>]’:
../src/hb-ot-cff1-table.hh:554:13:   required from here
../src/hb-ot-cff1-table.hh:377:60: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
       if (unlikely (!ranges[i].sanitize (c) || (num_glyphs < ranges[i].nLeft + 1)))
                                                ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

Enabling the extra cast operator mentioned in previous commit to see if
that fixes this case.

Again, I'd be happy to say "use 1u instead of 1" if this was universally
erred on.  But since some compilers happily compile this while others
err, it would be a huge headache. Let's see...

https://github.com/harfbuzz/harfbuzz/pull/2875
This commit is contained in:
Behdad Esfahbod 2021-02-22 22:33:17 -07:00
parent 567cedcc5f
commit 0983601399
1 changed files with 5 additions and 0 deletions

View File

@ -64,6 +64,11 @@ struct IntType
IntType& operator = (Type i) { v = i; return *this; }
operator Type () const { return v; }
template <typename Type2 = hb_conditional<hb_is_signed (Type), signed, unsigned>,
hb_enable_if (sizeof (Type) < sizeof (Type2))>
operator hb_type_identity_t<Type2> () const { return v; }
bool operator == (const IntType &o) const { return (Type) v == (Type) o.v; }
bool operator != (const IntType &o) const { return !(*this == o); }