Subject: Re: alloca() question
To: None <firstname.lastname@example.org>
From: Mike Long <email@example.com>
Date: 07/12/1996 21:43:33
>From: firstname.lastname@example.org (J.T. Conklin)
>Date: Fri, 12 Jul 1996 14:36:01 -0700 (PDT)
>> I recently found that, at least on the 386, alloca() doesn't return
>> NULL when the stack limit is reached. Is it a bug or a feature ?
>I don't think alloca() returns NULL when the stack limit is reached
>on other architectures either. Usually it is implemented as a simple
>adjustment of the stack pointer.
Be careful if you try to UTSL for alloca(); GCC usually substitutes
its __builtin_alloca() instead. There is another implementation in
libgnumalloc.a, so we have three different implementations in this
>> If it's a feature, the alloca() man page is false.
>I take it you mean the sentance "If the allocation failed, a NULL pointer
>IMO, that sentance should be removed.
I just looked at the malloc(3v) page on the StunOS box in front of
which I'm sitting, and I noticed a curious discrepancy: The
description of alloca() states, "Note that if the allocated block
is beyond the current stack limit, the resulting behavior is
undefined." But the same page later states, "On failure, [malloc(),
..., and alloca()] return NULL." So our confusion is hardly
Mike Long <email@example.com> <URL:http://www.shore.net/~mikel>
VLSI Design Engineer finger firstname.lastname@example.org for PGP public key
Analog Devices, CPD Division CCBF225E7D3F7ECB2C8F7ABB15D9BE7B
Norwood, MA 02062 USA (eq (opinion 'ADI) (opinion 'mike)) -> nil