"BGreene" <ba****@highstream.net> writes:
Keith Thompson <ks***@mib.org> writes: The standard uses the term "address" to mean a pointer value. So if
you follow the terminology of the standard, it's trivially true that
pointers store just addresses. You just need to be aware that they
aren't necessarily "addresses" in the low-level sense used by most
people.
Could you please clarify this?
The usual (non-C) sense of the term "address" is a virtual or physical
address recognized by the CPU and/or memory management system.
The C standard uses the term "address" to mean a C pointer value. For
example, the unary "&" (address-of) operator yields an address value.
The C standard defines the semantics, but doesn't say much about the
representation. An "address" in the C sense could be some
higher-level construct than a virtual or physical machine address.
It's an address in the C abstract machine, not necessarily in the
physical machine.
In most implementations, C addresses (pointer values) are machine
addresses, but the C standard is designed to allow a variety of
implementation strategies.
One concrete example is the C implementation on Cray vector machines.
A machine-level address is a 64-bit quantity that points to a 64-bit
machine word, but the C compiler has CHAR_BIT==8, so it needs a
mechanism to point to 8-bit bytes within words. An int* pointer is a
machine address, but a char* or void* pointer has a 3-bit offset
stored in the otherwise unused high-order bits of a word pointer.
This is implemented entirely in code generated by the compiler, not in
hardware. A char* pointer value with a non-zero offset field is a C
address, but it's not a machine address.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.