Local Variable Storage Scope
Henry Spencer
henry at zoo.toronto.edu
Wed Jul 25 01:15:30 AEST 1990
In article <1990Jul23.230418.15169 at uunet!unhd> al at uunet!unhd (Anthony Lapadula) writes:
> { 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?
Certainly. local1 exists only inside the first block, local2 exists only
inside the second, so it is perfectly legitimate to re-use the storage that
used to hold local1 for local2. Mind you, there is no promise that this
will be done.
--
NFS: all the nice semantics of MSDOS, | Henry Spencer at U of Toronto Zoology
and its performance and security too. | henry at zoo.toronto.edu utzoo!henry
More information about the Comp.lang.c
mailing list