[HarfBuzz] enum issue

Behdad Esfahbod behdad at behdad.org
Tue Mar 4 16:33:29 PST 2014

On 14-03-04 04:07 PM, Richard Wordingham wrote:
> On Tue, 04 Mar 2014 14:45:12 -0800
> Behdad Esfahbod <behdad at behdad.org> wrote:
>> On 14-03-04 02:29 PM, Richard Wordingham wrote:
>>> On Tue, 04 Mar 2014 10:47:47 -0800
>>> Behdad Esfahbod <behdad at behdad.org> wrote:
>>>> That negates the reason we added that line to begin with, which was
>>>> to ensure all hb_tag_t's fit in hb_script_t.  How about:
>>>> The idea being that DUMMY2 gets value of 0x80000000, ensuring that
>>>> hb_script_t can represent up to 0xFFFFFFFF.
>>> But the value of DUMMY2 is not a value of (32-bit) int!
>> Read again what Jonathan wrote:
>> """
>> ISO C says:
>>   Each enumerated type shall be compatible with char, a signed
>>   integer type, or an unsigned integer type. The choice of type is
>>   implementation-defined, but shall be capable of representing the
>>   values of all the members of the enumeration.
>> which is fine, but it also says:
>>   The expression that defines the value of an enumeration constant
>>   shall be an integer constant expression that has a value
>>   representable as an int.
>> """
> The next paragraph of C99 reads, removing (irrelevant) footnote
> references:
> "The identifiers in an enumerator list are declared as constants that
> have type *int* and may appear wherever such are permitted. An
> enumerator with = defines its enumeration constant as the value of the
> constant expression. If the first enumerator has no =, the value of its
> enumeration constant is 0. Each subsequent enumerator with no = defines
> its enumeration constant as the value of the constant expression
> obtained by adding 1 to the value of the previous enumeration
> constant.  (The use of enumerators with = may produce enumeration
> constants with values that duplicate other values in the same
> enumeration.) The enumerators of an enumeration are also known as its
> members."
> Are you claiming that DUMMY2 will have type *int* but will
> nevertheless have value 0x80000000?  Note that this is a value that is
> not representable as *int* if one use 2's complement 32 bit integers. 

Right.  And I get a compile error:

a.c:5:2: error: overflow in enumeration values

At this point I'm happy to call the warning an idiosyncrasy of ISO C and one
that I'm happy to ignore.  Gcc seems to agree, by only generating the warning
under -pedantic.


More information about the HarfBuzz mailing list