F
Frederick Gotham
I think someone posted elsewhere on the group that we must be able to
address at least 65 535 bytes in C... ? (Or something along those lines).
A 16-Bit unsigned integer type has 65 536 unique values. If our char
pointer is 16-Bit, then it too can contain 65 536 unique values. Take
away 1 for the null pointer value, and we have 65 535 unique byte
addresses.
So, at first glance, it looks like a 16-Bit char pointer is just about
sufficient to satisfy C's need for 65 535 bytes.
However, adding to the debate about:
char buffer[64];
const char * const p_null = 0;
const char * const p_over = buffer + 64;
assert( p_null == p_over );
If, hypothetically speaking, the pointer to "one past last" could NOT be
equal to the null pointer, then the addresses would have to be
distributed something like the following:
0x0000 to 0xFFFD inclusive : Valid byte addresses
0xFFFE : Pointer to "one past last"
0xFFFF : Null pointer value
The problem with this, however, is that 0x0000 to 0xFFFD inclusive
constitutes only 65 534 unique addresses... and this seems to not satisfy
C's need for 65 535 bytes.
So it seems to me that if p_over can't be equal to p_null, then char*
must be at least 17-Bit.
Any thoughts?
address at least 65 535 bytes in C... ? (Or something along those lines).
A 16-Bit unsigned integer type has 65 536 unique values. If our char
pointer is 16-Bit, then it too can contain 65 536 unique values. Take
away 1 for the null pointer value, and we have 65 535 unique byte
addresses.
So, at first glance, it looks like a 16-Bit char pointer is just about
sufficient to satisfy C's need for 65 535 bytes.
However, adding to the debate about:
char buffer[64];
const char * const p_null = 0;
const char * const p_over = buffer + 64;
assert( p_null == p_over );
If, hypothetically speaking, the pointer to "one past last" could NOT be
equal to the null pointer, then the addresses would have to be
distributed something like the following:
0x0000 to 0xFFFD inclusive : Valid byte addresses
0xFFFE : Pointer to "one past last"
0xFFFF : Null pointer value
The problem with this, however, is that 0x0000 to 0xFFFD inclusive
constitutes only 65 534 unique addresses... and this seems to not satisfy
C's need for 65 535 bytes.
So it seems to me that if p_over can't be equal to p_null, then char*
must be at least 17-Bit.
Any thoughts?