leo@philmds.UUCP (Leo de Wit) (09/14/88)
In article <718@proxftl.UUCP> bill@proxftl.UUCP (T. William Wells) writes: [lines deleted...] >Pardon, but the question of what happens to local variables when >entering a loop from other than the top has never been an obscure >issue in C. Both K&R and ANSI assert that the locals will *not* >be initialized, and K&R implies and ANSI explicitly states that >the memory for the locals will be allocated. > >I also don't know of any compiler that fails to allocate space in >this situation. Does anyone know of any? Just to add my two cents worth: A clever (or should I say: not too dumb) compiler can avoid to allocate space explicitly for an inner block: the maximum space needed is claimed on entry of the function. In this way no overhead for stack frame manipulation of inner blocks is needed. Besides this there are two advantages of using inner block automatics: data hiding - only declare variables where you need them - and efficient storage usage - two inner blocks at the same level share the stack for their automatic variables. To use a variation of the previous poster's question: does anyone know of any compiler that does not already allocate all the stack space needed at entrance of the function? Leo.
meissner@xyzzy.UUCP (Usenet Administration) (09/26/88)
In article <803@philmds.UUCP> leo@philmds.UUCP (Leo de Wit) writes: | To use a variation of the previous poster's question: does anyone know | of any compiler that does not already allocate all the stack space | needed at entrance of the function? Some of Data General's other compilers do this (notably PL/1 and DG/L). In addition to the normal add/subtract of the stack pointer, the code generator detects jumping into blocks, it has to allocate the space, as well as removing the space on a jump out of a block. -- Michael Meissner, Data General. Uucp: ...!mcnc!rti!xyzzy!meissner Arpa: meissner@dg-rtp.DG.COM (or) meissner%dg-rtp.DG.COM@relay.cs.net