tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: alloca again
On Mon, Oct 03, 2022 at 09:33:47AM -0400, Mouse wrote:
> >>> I'd argue that providing alloca(3) as anything except a compiler
> >>> builtin is a bug, and that kind of thing should never be used.
> >> I'd argue that alloca should never be used and actually should never
> >> have existed. As far as I can see it does nothing that can't be
> >> done better - more portably and correctly - by variable-sized
> >> arrays. Am I missing something?
> > I look forward to you fixing every piece of third-party code using it
> > in the wild. :)
>
> That sounds like a "no" to my question (which was independent of what
> does or doesn't try to use alloca). Is it?
>
> I don't see any reason I should be responsible for fixing other
> people's nonportable code. (Nor, for that matter, do I see any reason
> NetBSD should be responsible for supporting their choices of
> nonportabilities. I consider code that uses alloca() to be on a par
> with code that uses, say, SCM_SECURITY ancillary data, sys$crmpsc(), or
> #pragma aux: it's choosing to use a nonportable feature.)
>
> Would you have reacted the same if I'd argued against support for, say,
> the routines typically declared by <conio.h>? Why or why not?
If you propose to remove something, and thereby break code that
previously worked, you also need to propose to deal with those
consequences. We don't have a <conio.h> compat layer; we do have
alloca, and since alloca has historically existed in Unix for a long
time there is a fair amount of old software that uses it.
If you would like to contribute to an effort to fumigate pkgsrc for
alloca uses, please go ahead. We have fairly successfully killed off
other dead interfaces (e.g. union wait, <sgtty.h>) and it's mostly a
matter of being willing to run the test builds and patch the
failures. However, iirc you won't touch pkgsrc for some reason :-p
Also, depending on how you interpret the interaction of alloca and the
C standard, the aliasing rules may preclude using variable-length
arrays as a general replacement. That is, it's reasonable to interpret
it as being like malloc and returning untyped memory, whereas any
array you declare is automatically typed.
--
David A. Holland
dholland%netbsd.org@localhost
Home |
Main Index |
Thread Index |
Old Index