[HarfBuzz] enum issue

Richard Wordingham richard.wordingham at ntlworld.com
Tue Mar 4 00:05:02 PST 2014

On Tue, 04 Mar 2014 05:24:56 +0000
Jonathan Kew <jfkthame at googlemail.com> wrote:

> That's what leads to the pedantic warning: we have HB_TAG_MAX defined
> as the hb_tag_t value of 0xffffffff, and hb_tag_t is uint32_t, so
> this is the integer 4294967295, which is not representable as an int.
> If we change the last value in the hb_script_t enumeration to
>    /*---*/ _HB_SCRIPT_MAX_VALUE = (int) HB_TAG_MAX
> i.e. add an explicit cast, then I believe we shouldn't get a warning. 
> However, this might mean the compiler will choose to represent the 
> hb_script_t enumeration as int instead of unsigned int (because one
> of its values will be negative). But AFAICT this should be harmless.

A few thoughts on this.  Firstly, the C99 specification says,

"Otherwise, the new type is signed and the value cannot be represented
in it; either the result is implementation-defined or an
implementation-defined signal is raised."

Secondly, https://www.microsoft.com/typography/otspec/otff.htm says:

"All tag names defined within a font (e.g., table names, feature tags,
language tags) must be built from printing characters represented by
ASCII values 32-126."

Consequently, shouldn't HB_TAG_MAX have the value of 0x7E7E7E7E, which
is a positive signed 32-bit integer and therefore avoids the problem
in the first place. 

I take it that any implementation where int is 16 bits would be told to
get back on the Ark.


More information about the HarfBuzz mailing list