Sizes, alignments, and maxima

Doug Gwyn gwyn at smoke.BRL.MIL
Thu Feb 23 15:41:12 AEST 1989


In article <11838 at haddock.ima.isc.com> karl at haddock.ima.isc.com (Karl Heuer) writes:
>Question for comp.std.c (to which I've redirected followups): I've been told
>that the Cray-2 has sizeof(int) == 8, yet INT_MAX == 0x7FFFFFFF (i.e. the
>arithmetic is only accurate to 4 bytes when using int).  Is this legal in a
>conforming implementation?  I think I can prove that UINT_MAX must be 2*^64-1,
>but I'm less sure about INT_MAX.  Section 3.1.2.5 has a restriction to binary
>architectures, which by the definition in the footnote seems to require every
>bit except the highest to represent a power of two; should this be interpreted
>as a requirement that 2*^63-1 must be representable in an 8-byte int?

I think an implementation such as you describe is legal.
What is required is that integers be represented in a binary
numeration system, that a nonnegative signed integer of a given size
have the same representation as the corresponding unsigned integer
with the same value, that all integers in the ranges given by INT_MAX
etc. be representable, and that unsigned arithmetic be performed
modulo UINT_MAX+1 (similarly for unsigned long, etc.).  I don't see
any way these requirements can be combined to "prove" that every bit
pattern contained in the "sizeof" soace has to be interpretable as a
valid integral value.  In fact I'm pretty sure we didn't want to
require that, since (as you note) some architectures really don't
support it.



More information about the Comp.std.c mailing list