From b4c61130324455bfd42095b01fa14ac901e441f1 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 10 Nov 2018 16:35:39 -0500 Subject: [PATCH] Try fixing MSVC 2008 build Fixes https://github.com/harfbuzz/harfbuzz/issues/1374 --- src/hb-open-type.hh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 6d6dd7b27..56fa43345 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -337,8 +337,16 @@ struct UnsizedArrayOf { HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type); - inline const Type& operator [] (unsigned int i) const { return arrayZ[i]; } - inline Type& operator [] (unsigned int i) { return arrayZ[i]; } + /* Unlikely other places, use "int i" instead of "unsigned int i" for our + * indexing operator. For two reasons: + * 1. For UnsizedArrayOf, it's not totally unimaginable to want to look + * at items before the start of current array. + * 2. 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 [] (int i) const { return arrayZ[i]; } + inline Type& operator [] (int i) { return arrayZ[i]; } template inline operator T * (void) { return arrayZ; } template inline operator const T * (void) const { return arrayZ; }