Re: Porting GCC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/09/2025 19:47, Segher Boessenkool wrote:
On Tue, Sep 09, 2025 at 07:28:39PM +0200, Arsen Arsenović wrote:
Shiva Subramanian via Gcc-help <gcc-help@xxxxxxxxxxx> writes:

For some reason, configure/make assumes that the section of regex.c in
libiberty that uses alloca needs to be used on Nonstop.

'alloca' is a standard C feature.  It is nether "older" nor replaced by
malloc - they do different things.

Your platform should provide both.

Yup.  Some *very* old programs used alloca where "malloc" would he more
modern style.  The two do similar things, but they aren't completely
interchangeable.  alloca() is a nicer interface for some programming
styles.

alloca() isn't C standard, and it isn't even POSIX, but most systems
do have it.  C variable length arrays *are* standard C (of course), and
they are often implemented using alloca().


Surely VLA's can't be implemented using alloca() ? They can both be implemented by similar compiler magic, but AFAIUI the allocations have different lifetimes. VLA's lifetimes start with their definitions, and end when they leave scope, while alloca() lifetimes start with the "call" to alloca(), and end with the return from the containing function. It won't often make a difference, but it might if you are doing odd things like allocating inside a block and using the space outside it, or doing the allocations inside a loop.





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux