scope of malloc

Richard Tobin richard at aiai.ed.ac.uk
Wed Nov 14 03:36:34 AEST 1990


In article <4251 at goanna.cs.rmit.oz.au> ok at goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
>Any processor that can't implement alloca() as a built-in operation is
>going to have a hard time with PL/I, Fortran 90, and Ada, all of which
>allow the declaration of local variables whose size is not known until
>the declaration is elaborated.  The fact that gcc supports alloca() as
>well as "auto int foo[some_expr()]" is not a coincidence.

alloca() is in fact somewhat more powerful than variable-size locals,
since you can do an alloca() anywhere, rather than just at the start
of a function - even inside a loop.  [Of course, if the variable size
of your autos is determined by an arbitrary expression then "not just
at the start of a function" means little.]

Does this cause additional implementation problems on any
architectures?

-- Richard

-- 
Richard Tobin,                       JANET: R.Tobin at uk.ac.ed             
AI Applications Institute,           ARPA:  R.Tobin%uk.ac.ed at nsfnet-relay.ac.uk
Edinburgh University.                UUCP:  ...!ukc!ed.ac.uk!R.Tobin



More information about the Comp.lang.c mailing list