[cfe-dev] Inconsistent types used to represent bitwidth

Chris Lattner clattner at apple.com
Thu Oct 4 08:02:22 PDT 2007


On Oct 4, 2007, at 7:44 AM, Cédric Venet wrote:
>>>> IIUC, the bitwidth is most of the time the number of bits needed to
>>>> represent the size, i.e. 32 for uint32_t. In this case 64 is the
>>>> largest number these kind of variables will ever hold, no?
>>>
>>> Yes, except that what is the size of "uint32_t[100000000000LL]" ?
>>
>>    sizeof(uint32_t[100000000000LL]) < 2^64,
>>
>> so the size is representable with 64 bits, which means the  
>> corresponding
>> bitwidth is not even '64', which conveniently fits into a int8_t.
>>
>> But probably I'm getting something really wrong here.
>> Regards Hartmut
>
> I think we lost the correct definition of bitwith along the way.
> quoting earlier post from this thread:
>
>>>>> recognized, that the bitwith (size of a type in bits) is
>
> for me, bitwith( X ) == 8*sizeof( X )
>
> If we speak of the same things, this was done in order to thread the
> size of bitfield member in an uniform manner with other 'normal'
> variable.

Yep, exactly!

-Chris



More information about the cfe-dev mailing list