Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!husc6!rutgers!bellcore!faline!ulysses!gatech!emory!platt
From: platt@emory.uucp (Dan Platt)
Newsgroups: comp.lang.c
Subject: Re: How are local vars allocated?
Message-ID: <2353@emory.uucp>
Date: Fri, 27-Nov-87 17:04:55 EST
Article-I.D.: emory.2353
Posted: Fri Nov 27 17:04:55 1987
Date-Received: Mon, 30-Nov-87 00:47:44 EST
References: <9367@mimsy.UUCP> <1633@megatest.UUCP> <1987Nov22.085210.20641@sq.uucp> <2218@killer.UUCP> <6749@brl-smoke.ARPA>
Reply-To: platt@emory.UUCP (Dan Platt)
Organization: Emory University
Lines: 13
Summary: usually on a stack.

===================================================================
Actually, it might be worthwhile to point out that in several compilers,
locally defined variables are placed on the stack as needed, and popped when
you've left the loop.  Since there may be other stuff being put on the stack
and being popped in between your accesses once you've left the {} where
a variable was assigned, you can't assume the 'first use' in the {} will
be the same as the value it had the last time you were in the {}.  This is
also how re-entrant and recursive code is handled: the arguments AND the
local variables are allocated space on the stack, so that when the routine
returns a value to the older version of itself, all its information is still
sitting there waiting for it on the stack.

Dan Platt