alloca (was Re: Are yacc parsers portable ?)

David DiGiacomo david at sun.uucp
Tue Aug 2 10:55:34 AEST 1988


In article <62170 at sun.uucp> swilson at sun.UUCP (Scott Wilson) writes:
>My main complaint with Bison was that both the source for Bison (last I
>looked) and the parser it produces rely on alloca - a method for allocating
>space on the stack that is automatically reclaimed when the function
>that calls it exits.  Alloca is found on BSD derived systems and
>I am told on other UNIX's.  It, however, is less than universally
>available (the manual page states:  "alloca() is both machine- and
>compiler-dependent; its use is discouraged").  I had a rather protected
>mail war with several people associated with Bison and/or FSF regarding
>this.  My opinion was that FSF would be doing computer users a greater
>service by writing more portable code when possible.

The FSF people aren't evil (?), they just disagree with the author of that
man page blurb about the usefulness and implementation difficulty of
alloca.  By distributing excellent software which makes good use of
alloca, they are ensuring that all self-respecting C compiler/library
vendors will provide an efficient implementation of it.  They even help
out the alloca-deprived by providing Doug Gwyn's malloc based alloca.
Seems reasonable to me!

-- 
David DiGiacomo, Sun Microsystems, Mt. View, CA  sun!david david at sun.com



More information about the Comp.lang.c mailing list