I'm not certain that the standard actually addresses 1-bit signed bitfields
in a consistent manner.
In 6.2.6.2 (Integer types), the standard says that a signed integer type
will have a single sign bit, some optional padding, and value bits. It is
emphatic that the padding is optional, and emphatic that the sign bit is
required, but I cannot tell if the value bits are /required by the
standard/ or not.
6.2.6.2 Integer types
...
2 For signed integer types, the bits of the object representation shall be
divided into three groups: value bits, padding bits, and the sign bit.
There need not be any padding bits; there shall be exactly one sign bit.
A bitfield is considered as an integer type, and a signed bitfield is a
signed integer type. Thus, a signed bitfield (of any length) /must/ have a
sign bit. It is not clear to me whether a signed bitfield is required to
carry any value bits.
A single-bit signed bitfield obviously carries a sign bit, and that sign bit
indicates a positive value (when 0) or a negative value (when 1). But,
since that sign bit is the only bit in a single-bit signed bitfield, there
is obviously no room for value bits. So, one interpretation of the C99
standard is that single-bit signed bitfields can not have a value; they
carry sign information only.
Another interpretation might be that the value of a single-bit signed
bitfield is not defined by the standard, and may be illegal. For that
matter, such a field may only carry trap representations, as 6.2.6.2 sub 2
suggests
Which of these (sign/value combinations) applies is implementation-defined,
as is whether the value with sign bit 1 and all value bits zero (for the
> =========================================================
first two (sign/magnitude and two's complement), or with sign bit and all
> =========================
value bits 1 (for one’s complement), is a trap representation or a normal
> ============ ========================
value.
Perhaps this is a question best asked in the comp.std.c arena
--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
Me:
http://pitcher.digitalfreehold.ca/ | Just Linux:
http://justlinux.ca/
---------- Slackware - Because I know what I'm doing. ------