diff options
author | Behdad Esfahbod <behdad@behdad.org> | 2018-11-16 16:48:28 -0800 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2018-11-16 16:48:28 -0800 |
commit | 0328a1ce41611ed981d41384ae5727479699f3a0 (patch) | |
tree | e186c4aa6e25c6a211f4042998b813f9073ba952 | |
parent | 52f61cdb87b67ef42a25288d8624170d0b6d3a25 (diff) |
Was causing more trouble than it solved. We use unsigned for indexing,
and it's not helpful to allow that wrapping to negative integers on
32bit machines. The only way we could work around it would have been
by accepting int64_t arg, but that's overkill.
Ignore the MSVC 2008 build issue. We don't support that compiler.
-rw-r--r-- | src/hb-open-type.hh | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index bae73da4..c77c25fa 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -339,25 +339,16 @@ struct UnsizedArrayOf HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type); - /* Unlikely other places, use "ssize_t i" instead of "unsigned int i" for our - * indexing operator. For three reasons: - * 1. For UnsizedArrayOf, it's not totally unimaginable to want to look - * at items before the start of current array. - * 2. Use the largest type, to help detect overflows. - * 3. Fixes MSVC 2008 "overloads have similar conversions" issue with the - * built-in operator [] that takes int, in expressions like sizeof (array[0])). - * I suppose I could fix that by replacing 0 with 0u, but like this fix - * more now. */ - inline const Type& operator [] (ssize_t i) const + inline const Type& operator [] (unsigned int i) const { const Type *p = &arrayZ[i]; - if (unlikely ((0 <= i) != (arrayZ <= p))) return Null (Type); /* Over/under-flowed. */ + if (unlikely (p < arrayZ)) return Null (Type); /* Overflowed. */ return *p; } - inline Type& operator [] (ssize_t i) + inline Type& operator [] (unsigned int i) { const Type *p = &arrayZ[i]; - if (unlikely ((0 <= i) != (arrayZ <= p))) return Crap (Type); /* Over/under-flowed. */ + if (unlikely (p < arrayZ)) return Crap (Type); /* Overflowed. */ return *p; } |