Local Variable Storage Scope
Anthony Lapadula
al at uunet!unhd
Tue Jul 24 09:04:18 AEST 1990
I've found some interesting behaviour in our current C compiler (gcc 1.36).
void f()
{
{ int local1[100]; /* some code goes here */ }
{ int local2[100]; /* more code goes here */ }
}
Is the compiler allowed to allocate just enough space for only
one of the local arrays? That is, can ``local1'' and ``local2''
share the same spot on the run-time stack?
Gcc does *not* do this, but instead reserves enough room on the
stack for both arrays. I couldn't come up with an explanation
for this behaviour. Is there one?
BTW, the code in question is being generated by another program.
*Lots* of local arrays are declared, but the code must run on a
machine with 512K RAM and no VM -- so every bit of stack space helps.
-- Anthony (uunet!unhd!al) Lapadula
More information about the Comp.lang.c
mailing list