Is range(ptrdiff_t) > range(size_t)?

Felix Lee flee at blitz.cs.psu.edu
Thu Jul 28 06:06:30 AEST 1988


Harbison&Steele (2e) says (p. 156)
> Some implementations of C use int or long int as the type of the
> result of sizeof, but this is an inferior choice because it may be
> impossible to represent the size of a very large array, say one that
> spans more than half the total address space.

But such a large array breaks ptrdiff_t.  Is ptrdiff_t required to
have a larger range than size_t?  Can you stuff a size_t value into a
ptrdiff_t variable without overflow?  Is the following relationship
always true?
	sizeof(char a[]) == &a[sizeof(a)] - &a[0]
--
Felix Lee	*!psuvax1!flee



More information about the Comp.lang.c mailing list