Section 6.3.1.1 of the C99 standard contains:
The following may be used in an expression wherever an
int
orunsigned int
may be used:[...] A bit-field of type
_Bool
,int
,signed int
, orunsigned int
.If an
int
can represent all values of the original type, the value is converted to anint
; otherwise, it is converted to anunsigned int
.
It seems to me that this implies that unsigned int
bit-fields are promoted to int
, except when the width of the unsigned bit-field is equal to the width of int
, in which case the last phrase applies.
I have the following program:
struct S { unsigned f:32; } x = { 28349};
unsigned short us = 0xDC23L;
main(){
int r = (x.f ^ ((short)-87)) >= us;
printf("%d\n", r);
return r;
}
And two systems to execute this program (int
is 32-bit on both systems). One system says this program prints 1, and the other says that it prints 0. My question is, against which of the two systems should I file a bug report? (I am leaning towards filing the report against the system that prints 0, because of the excerpt above)