Thanks Richard for your reply.
So, if the implementation (with int = 4bytes = 32 bits) chose +32767
as the highest value, does that mean all the
values from +32768 to +2147483647 are trap representation
on this implementation ?
Not quite. The way you described it, you have 16 padding bits. If you
store lets say 32767 into an int value, you will have a sign bit that
is set to zero, fifteen value bits all set to 1, and 16 padding bits
set to some value that the implementation thinks is right. For
example, the padding bits could be all zero, or they could be copies
if the sign bit and the value bits.
By accessing the four bytes of the int using an unsigned char*, you
may be able to figure out which bits are sign bit, value bits and
padding bits (For example, this would work in an implementation where
the padding bits are always zero; if the padding bits are always
copies of other bits, you can't find out which are padding bits). If
you know the padding bits, you could modify padding bits by accessing
the int using an unsigned char*.
The implementation defines what happens: If the implementation says
that there are no trap representations, then storing anything into the
padding bits is legal and doesn't change the value. You store 32767
into an int, change the padding bits any way you like, and the value
in the int is still 32767. On the other hand, the implementation could
say that any setting of the padding bits other than the one it prefers
is a trap representation. Again, store 32767, change the padding bits,
try reading the int, and you get undefined behaviour.
Anyway, the way you wrote it is quite imprecise. You couldn't store a
value of 32768 into an int because there is no such value. You could
say something like "Whenever I store a value from -32768 to 32767, the
representation of the result is the same as on my other computer which
uses a PowerPC processor with INT_MIN/MAX = -2^31, 2^31-1. What
happens if I create a representation that looks like 32768 looks on my
other computer?", but there is no such value as 32768.