Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!snorkelwacker!apple!escher From: escher@Apple.COM (Michael Crawford) Newsgroups: gnu.gcc Subject: Re: A question on local variable allocation Message-ID: <6915@internal.Apple.COM> Date: 27 Feb 90 00:44:33 GMT References: <25E58087.11649@paris.ics.uci.edu> Organization: Apple Computer Inc, Cupertino, CA Lines: 45 In article <25E58087.11649@paris.ics.uci.edu> rfg@paris.ics.uci.edu (Ronald Guilmette) writes: >Can someone please explain to me why, in the following code, the space >allocated for the two local array variables does not overlap? > ... > void function () > { > { > int inside1[1024]; > > g (inside1); > } > > { > int inside2[1024]; > > g (inside2); > } > } > I believe the reason is that C allows one to goto the inside of a block from the outside, as long as the goto is within the same function. This would allow one to jump back and forth between the two blocks given. I admit, though, that the optimizer ought to note the absence of any goto's or labels within the function block, and do the allocation as you suggest, with it overlapping. By the way, the allocation of the arrays on the stack is done at the time the function is entered (in general -- I do not know much about gcc). I could image there could be some trouble with alloca() working properly if called inside, or outside of the blocks. -- Michael D. Crawford Oddball Enterprises 694 Nobel Drive Santa Cruz, CA 95060 oddball!mike@ucscc.ucsc.edu Consulting for Apple Computer Inc. escher@apple.com The opinions expressed here are solely my own.