Stack Frames
COTTRELL, JAMES
cottrell at NBS-VMS.ARPA
Wed Feb 19 10:16:42 AEST 1986
> In article <463 at ur-helheim.UUCP> dave at ur-helheim.UUCP (Raver Dave) writes:
> >
> >In c one can declare variables within any {} block. Does a
> >{} pair *imply* new context, with stack frame shifts, etc.
> >I would have to assume so if local variables are declared
> >within the {} but if no variables are declared? ...
> >
> >The reason for asking is for ease of expansion and
> >consistancy of formatting I often put {} blocks where
> >they are not necessary (clauses that are only one
> >statement). Am I paying a penalty for these one-statement
> >clauses or will my trusted compiler note the context has
> >not changed and inhibit the subsequent costly stack manipulations?
To which Dagwynn responds:
> If your C compiler generates additional overhead for local
> blocks, it is not very good. Most reasonable implementations
> reserve enough stack at function entry for the deepest local
> block nesting within the function, so that there is no
> run-time action required upon entering a local block.
Not only `not very good' but seemingly impossible. If a separate
stack frame was created, access to arguments would be different
within the new block. Still doable, but now try jumping in or
out of the block. Getting Hairy!
My experience is that the variable is allocated as if it were
declared local to the funxion, but with it's scope restricted
to the new block. Doug is correct. Fear not, it's cool.
jim cottrell at nbs
*/
------
More information about the Comp.lang.c
mailing list