back to the (ivory) tower

John Woods john at frog.UUCP
Thu Jun 9 13:55:00 AEST 1988


In article <16018 at brl-adm.ARPA>, ted%nmsu.csnet at relay.cs.net writes:
> The 4.3 manual entry for alloca says:
>     BUGS
>          Alloca is both machine- and compiler-dependent; its  use  is
>          discouraged.
> On the other hand, alloca is often used and strongly supported by the
> gnu camp (n.b. heavy use in emacs and bison)....
> It is also true that alloca is almost trivial to implement on most
> machines (say with a macro which expands to a single machine
> instruction to in(de)crement the stack pointer).
> What is the opinion of the masses?  Is alloca really such a problem
> across differing architectures?  Is it really that useful?

Architecture is not the only problem, as the manual entry hints; many
compilers make alloca() impossible to use.  What's more, it's GOOD that they
do so:  many optimizing compilers pull stunts with the stack like not
resetting the stack pointer after each function call, so as to save time.
Others dispense with a frame pointer entirely, because they "know" where the
stack pointer will be in relation to the hypothetical frame pointer, and just
index off of it appropriately.  Some even do both.  Slowing down every single
program just so a couple of programs can be written without paying attention
doesn't seem the best of tradeoffs.
-- 
John Woods, Charles River Data Systems, Framingham MA, (617) 626-1101
...!decvax!frog!john, john at frog.UUCP, ...!mit-eddie!jfw, jfw at eddie.mit.edu

No amount of "Scotch-Guard" can repel the ugly stains left by REALITY...
		- Griffy



More information about the Comp.unix.wizards mailing list