[net.bugs.4bsd] Annoying C bug

joe@fluke.UUCP (Joe Kelsey) (08/10/83)

I have just run across an annoying little bug in the PCC treatment of
bit fields.  It seems that you cannot declare an unnamed bit field in
an "unsigned long" declaration!  "unsigned <anything else but long>"
works just fine!  For example, try declaring:

struct xyzzy {
	unsigned long
		b1 : 1,
		: 1,
		b2 : 1;
};

and PCC will complain about "illegal field type" at the nameless field.
You can then change the "long" to "int", "short", "char", and no
complaints!  You can also use just "unsigned" with no qualifier and it
also works.  This caused me some grief when I started using "unsigned
long" for 32-bit wide bit field definitions for consistency with my
other declarations of "unsigned short", etc.  This is only an
annoyance, since there is a work-around, but it seems that PCC is
acting rather inconsistently.

/Joe

mjs@rabbit.UUCP (08/11/83)

Remember that the values a signed 1-bit field has are not immediately
obvious:  {0, -1}.  An unsigned 1-bit field has the more obvious
values: {0, 1}.
-- 
	Marty Shannon
UUCP:	{alice,rabbit,research}!mjs
Phone:	201-582-3199

alan@allegra.UUCP (08/12/83)

The fact that you can't use an unsigned long for a bit field
is not an "annoying C bug" in PCC.  In fact, it is C. 


	Alan Driscoll
	Bell Labs, Murray Hill