Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uwm.edu!rpi!brutus.cs.uiuc.edu!jarthur!uci-ics!rfg From: rfg@ics.uci.edu (Ronald Guilmette) Newsgroups: gnu.gcc Subject: Re: A question on local variable allocation Message-ID: <25EAFE2C.2545@paris.ics.uci.edu> Date: 27 Feb 90 22:24:44 GMT References: <25E58087.11649@paris.ics.uci.edu> <6915@internal.Apple.COM> Reply-To: rfg@ics.uci.edu (Ronald Guilmette) Organization: UC Irvine Department of ICS Lines: 56 In article <6915@internal.Apple.COM> escher@Apple.COM (Michael Crawford) writes: >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 cannot see what possible difference such jumps would make to anything. Do you know of some secret implementation problem? If so, please state it. >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. That should happen always. Without regard to *anything* the optimizer knows or does (or doesn't know or doesn't do). >By the way, the allocation of the arrays on the stack is done at the time the >function is entered I knew that. I'm not totally ignorant, just mostly so. > (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. Please state the problem so that us non-clarvoiants can think about it. >Michael D. Crawford >Oddball Enterprises Do you manufacture oddballs or just repair them? :-) // Ron Guilmette (rfg@ics.uci.edu) // C++ Entomologist // Motto: If it sticks, force it. If it breaks, it needed replacing anyway.