(I asked this question on the gcc-help mailing list, but no answer
yet. It seems no one there knows or is interested in the internals of
gcc. So, please forgive me for cross-posting the question here again.
)
Hello, everyone!
I'm with the latest MinGW, and following program:
-----------------------------------------------------------------------
char *p1, *p2;
int main(void)
{
{
char a[1024];
p1 = &a[0];
}
{
char a[1024];
p2 = &a[0];
}
printf("p1 - p2 = %d\n", p1 - p2);
return 0;
}
-----------------------------------------------------------------------
output:
> p1 - p2 = 1024
(Optimize or not makes no difference.)
That means the two arrays don't overlap on the stack. But since that
will save a significant amount of stack space, I wonder, why gcc don't
manage to make the two arrays share one same memory block of 1K bytes
on the stack?
BTW, I checked two embedded C compilers: CCS from TI and VisualDSP
from ADI, do the trick, outputing p1 - p2 = 0.
Thanks in advance.
Ding Curie