If the "smallest addressable unit" in C of
being type char apparently
doesn't mean that the machine has to be char-addressable.
Well, it does have to be in the sense that it has to be possible to
(somehow) refer to individual chars. It does not have to be
char-addressable in the sense of there being any machine-code object
which can be trivially indirected through to obtain a single C char.
Indeed, there is no _requirement_ that C use whatever indirection the
machine code level supports, though if there's a way to implement the C
abstract machine semantics without too much hair, it should be used.
I think there was once a C implementation for the Lisp Machine that
represented pointers as <array,index> pairs - Lisp arrays, of course.
I suppose it's even possible to create a C where
word addresses ==
char addresses; the char being aligned in a word, one char per word,
with the remainder of the word unsued.
Only if you never use the rest of the word for any purpose, because
copying something by pointer casting to char * or unsigned char * and
copying the chars has to copy the entire object. (The Lisp Machine
implementation above presumably took advantage of the way that model of
Lisp Machine allowed two arrays to overlay one another, sharing
storage.)
Do char and int addresses have to share the same
space?
Yes and no.
They have to share the same space in the sense that copying the chars
making up an object copies the object. They do not have to share the
same space in the sense that the conversion between (say) a
pointer-to-int and a pointer-to-char pointing to the first char making
up the int may be an arbitrarily complicated operation. (As a
quality-of-implementation issue, it's probably better that it not be
especially complicated, but that's not a conformance issue.)
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse at
rodents-montreal.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B