thomas@utah-gr.UUCP (Spencer W. Thomas) (07/16/84)
Index: lib/ccom 4.2BSD
Description:
When casting an unsigned bit field to a signed integer, sign extension
is done.
Repeat-By:
cc -S the following program. Note the ext instructions. Note also that
this problem does not appear for full size unsigned ints.
main()
{
int i;
unsigned short j;
struct {
unsigned int a : 3;
} a;
i = a.a;
i = (int)a.a;
i = j;
i = (int)j;
}
The (edited) output follows:
_main:
extzv $0,$3,_a,-4(fp)
extv $0,$3,_a,-4(fp)
movzwl -6(fp),-4(fp)
movzwl -6(fp),-4(fp)
ret