I'm unsure about that, see below.
Oh please feel free to call me by my first name. Hopefully it is
sufficiently unique that I'll know who you mean.
Right. The padding bits will either be set or unset... I was more
asking about whether they are directly complemented by the unary '~'
operator.
I've read 6.2.6.2 several times but didn't read anything about whether
or not unary '~' (and other bitwise friends) are restricted to
particular bit groups. I think it's clear from those two points you
reference that the padding bits are unspecified. What I'm wondering is
if they must toggle when one applies unary '~' to an operand. Still
unspecified, but in the other state. My interpretation is that they are
not defined to toggle, but I cannot prove it with the Standard.
Also see 6.5.3.3p1 and See 6.5.3.3p4
The operand of the unary ~ operator shall have integer type.
The result of the ~ operator is the bitwise complement of its
(promoted) operand (that is, each bit in the result is set if
and only if the corresponding bit in the converted operand is
not set). The integer promotions are performed on the operand,
and the result has the promoted type. If the promoted type is
an unsigned type, the expression ~E is equivalent to the
maximum value representable in that type minus E.
Because of *each*, I read this, even combined with 6.2.6.2,
as implying ~ inverts padding bits. One thing is sure: whatever
effect there is on padding bits has no incidence on the value
represented. The point is moot since the padding bit is a dodo,
or a even a dahu AFAIK.
Effect of ~ on the value and the possible occurrence of a trap
representation depends on if the promoted type is signed or
unsigned, and in the former case of which of the options in
6.2.6.2p2 (sign and magnitude, two's complement, one's
complement) is in effect.
Speaking of dodos, anyone know a machine, with a C compiler
in actual use, that does not use two's complement? Is there
support for keeping only that and/or dropping padding bits
in integer types in a forthcoming C standard?
Francois Grieu