Please elaborate. Why does that make a difference?
Paragraph 5 of ISO 9899:1999 section 6.5.8 "Relational operators", a
little thing that defines the standard C language:
<quote>
When two pointers are compared, the result depends on the relative
locations in the address space of the objects pointed to. If two
pointers to object or incomplete types both point to the same object,
or both point one past the last element of the same array object,
they compare equal. If the objects pointed to are members of the same
aggregate object, pointers to structure members declared later compare
greater than pointers to members declared earlier in the structure,
and pointers to array elements with larger subscript values compare
greater than pointers to elements of the same array with lower
subscript values. All pointers to members of the same union object
compare equal. If the expression P points to an element of an array
object and the expression Q points to the last element of the same
array object, the pointer expression Q+1 compares greater than
P. In all other cases, the behavior is undefined.
But they all have "automatic storage".
The typical implementation of automatic storage is on the program stack.
Name one.
All 8051 processors, limited to lowest 256 8-bit bytes.
All Philips XA processors, limited to lowest 64K 8-bit bytes.
All Texas Instruments TMS320C28xx DSPs, limited to lowest 64K 16-bit
bytes.
Once you leave the common desktop behind, there are quite a few
hardware architectures that limit their hardware stack to specific
regions of memory for a variety of reasons.
I don't know whether I have any sense or not.
But my assertion is easily tested:
All that proves is that the one implementation you know, from which
you probably formed the erroneous impression, works the way it works.
This says nothing at all about any other platform/implementation, or
what the language defines.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[]) {
//char c;
//char* p = &c;
char* p = (char*)malloc(sizeof(char));
if (p > (char*)(&p)) {
fprintf(stdout, "p probably points to a character "
"in automatic storage.\n");
}
else {
fprintf(stdout, "p probably points to static data "
"or free storage.\n");
}
return 0;
}
Actually it doesn't even prove that, since you neglected to show the
output of the program.