alloca() portability

Walter Bright bright at nazgul.UUCP
Sat Nov 17 08:52:52 AEST 1990


In article <27634 at mimsy.umd.edu> chris at mimsy.umd.edu (Chris Torek) writes:
/There may be major correctness losses using alloca (as I wrote earlier,
/any optimizing compiler can easily produce failing object code from
/apparently-correct source code if that source code uses alloca).

You're right. I struggled with this problem for a while, until the
solution became obvious: make alloca() a 'magic' function, and have
the optimizations take it into account. I implemented this, and it
works fine (including in those cases you pointed out, and the cases
in the MSC manual where it says not to use it).

ANSI C allows other functions to be magic.

But the fact remains that if you wish to write maximally portable programs
you are better off avoiding alloca.



More information about the Comp.lang.c mailing list