Xref: utzoo comp.lang.c:30482 gnu.gcc:1797 Path: utzoo!utgpu!watserv1!watmath!uunet!unhd!al From: al@uunet!unhd (Anthony Lapadula) Newsgroups: comp.lang.c,gnu.gcc Subject: Local Variable Storage Scope Message-ID: <1990Jul23.230418.15169@uunet!unhd> Date: 23 Jul 90 23:04:18 GMT Distribution: na Organization: Computing Information Services, University of New Hampshire Lines: 22 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