[HarfBuzz] Clang warnings while compiling HB trunk

Behdad Esfahbod behdad at behdad.org
Tue Oct 22 03:40:16 PDT 2013


On 13-10-22 10:17 AM, Jonathan Kew wrote:
> On 22/10/13 00:20, Behdad Esfahbod wrote:
>> On 13-10-20 01:44 PM, Shriramana Sharma wrote:
>>> Hello. I'm running Clang 3.2 on Kubuntu Saucy.
>>
>> Generally these warnings seem to be Ok.
> 
> Not entirely. The warning about OT_CM2 here:
> 
> hb-ot-shape-complex-indic.cc:166:27: warning: shift count >= width of type
> [-Wshift-count-overflow]
>   return is_one_of (info, CONSONANT_FLAGS);
>                           ^~~~~~~~~~~~~~~
> hb-ot-shape-complex-indic.cc:162:55: note: expanded from macro 'CONSONANT_FLAGS'
> #define CONSONANT_FLAGS (FLAG (OT_C) | FLAG (OT_Ra) | MEDIAL_FLAGS | FLAG
> (OT_V) | FLAG (OT_NBSP) | FLAG (OT_DOTTEDCIRCLE))
>                                                       ^~~~~~~~~~~~
> hb-ot-shape-complex-indic.cc:155:38: note: expanded from macro 'MEDIAL_FLAGS'
> #define MEDIAL_FLAGS (FLAG (OT_CM) | FLAG (OT_CM2))
>                                      ^~~~~~~~~~~~~
> ./hb-private.hh:818:19: note: expanded from macro 'FLAG'
> #define FLAG(x) (1<<(x))
>                   ^ ~~~
> 
> (occurs three times) looks legitimate to me; OT_CM2 is currently defined as
> 41, which means it can't be mapped to a position within a 32-bit flags word.
> 
> The fix would be to rearrange the classes such that the ones we care about
> using as flags are all <= 31.

Yes, I noticed that while checking why clang travis build failed.  I'll fix
these and all other warnings and make Travis consider warnings as errors.

BTW, it's not safe to use any number beyond 31 at all since shift >= width of
type is undefined in C and I've seen instances of the processor not doing what
you expect in such cases.  IIRC some processors, x86 even, ignore the top bits
of the shift count.

b

> JK
> 
> _______________________________________________
> HarfBuzz mailing list
> HarfBuzz at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/harfbuzz
> 

-- 
behdad
http://behdad.org/



More information about the HarfBuzz mailing list