|[5 earlier articles]|
|Re: What's wrong with alloca() ? David.Chase@Eng.Sun.COM (1991-12-23)|
|Re: What's wrong with alloca() ? firstname.lastname@example.org (1991-12-26)|
|Re: What's wrong with alloca() ? email@example.com (1991-12-30)|
|Re: What's wrong with alloca() ? firstname.lastname@example.org (1991-12-30)|
|Re: What's wrong with alloca() ? email@example.com (1991-12-31)|
|Re: What's wrong with alloca() ? GORMAN_B@prime1.lancashire-poly.ac.uk (Barry Gorman) (1992-01-03)|
|Re: What's wrong with alloca() ? firstname.lastname@example.org (1992-01-05)|
|Re: What's wrong with alloca() ? email@example.com (1992-01-05)|
|Re: What's wrong with alloca() ? firstname.lastname@example.org (1992-01-06)|
|From:||email@example.com (Pat Rankin)|
|Summary:||even when it's easy, alloca is unsafe|
|News-Software:||VAX/VMS VNEWS 1.41|
|Organization:||California Institute of Technology|
|Date:||Sun, 5 Jan 1992 02:55:00 GMT|
In article 92-01-011, Barry Gorman <GORMAN_B@prime1.lancashire-poly.ac.uk> writes...
> Some time ago, I implemented alloca() for the Pr1me '50 series. This has
> been used in a variety of applications without any problems being found.
>[... description of stack frame manipulation omitted ...]
It's pretty trivial to do the same thing on a VAX, at least when
the usual calling conventions are used. However, other systems don't
necessarily have nice clean stacks, so can pose difficulty.
> No compiler support is required; and nested
> function calls pose no problem.
Your method breaks when used with VAX C (DEC's C compiler for VMS).
Local variables can be reached with either a positive offset from the
stack pointer or a negative offset from the frame pointer. The compiler
usually uses the latter, but it may choose to use the former if that
offset is smaller (byte vs word, or word vs longword), so manipulating
the stack pointer behind its back is definitely unsafe. In other words,
compiler support _is_ required even though anybody could code their own
alloca() implementation. Munging the stack in such a way may also require
additional debugger support too. Matching calls and returns can be tough
if some of the latter have been shortcircuited by jumps. ;-)
Pat Rankin, firstname.lastname@example.org
Return to the
Search the comp.compilers archives again.