[cfe-dev] [llvm-dev] Unsigned Bitwise Shift for Bit-field Structure

Shiva Chen via cfe-dev cfe-dev at lists.llvm.org
Fri Apr 21 08:31:21 PDT 2017


>> > On 21 Apr 2017, at 08:59, Shiva Chen via cfe-dev
>> > <cfe-dev at lists.llvm.org> wrote:
>> >
>> > Hi Hubert and Liu Hao,
>> >
>> > Thanks for your guidance and make the question more clear.
>> > When the value is not stored back into the bit-field member, it will
>> > involve integer promotion.
>> > The integer promotion rule for bit-filed defined in C99 6.3.1.1/2.
>> > However, the integer promotion rule for other implementation-defined
>> > bit-field type
>> > (width wider than int such as unsigned long long bit field type) was not
>> > clear.
>
> It is unclear as to the intent of the committee; however, the wording has:
> "All other types are unchanged by the integer promotions."

Agreed, there is default rule not promote other type.
But it is unclear that the committee intend not to promote for long
long bit field.
Therefore, there are some discussion in  DR #315.
Thanks for brought me here ^^

>
>>
>> > So the question become should the implementation-defined bit-field
>> > type do the promotion.
>>
>> > GCC choose not to and Clang will.
>> > There is some discussion in
>> > http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_315.htm
>> > As Hubert said, the answer will determine until the C standard mention
>> > the rule for implementation-defined bit-field type.



More information about the cfe-dev mailing list