Re: inline functions vs. alloca()

phil-news-nospam@xxxxxxxx writes:

If a C compiler such as GCC compiles a function as inline to the code
that was calling it, and that function calls alloca() to allocate some
space for its brief internal use, does that allocated memory still take
up stack space beyond where the inlined code is? If that happens and
the inlined code is allocating large space and/or is "called" inside a
loop, it would seem the stack could quickly become exhausted. I would
hope the compiler will at least restore the stack pointer so at the end
it is the same as at the beginning.

You'll probably get the most accurate answer by trying it out. If the
compiler supports it, you're probably better off with variable sized

Måns Rullgård

Relevant Pages

  • Re: What is a stack frame?
    ... There is no need for a separate "this frame" pointer. ... In any case, the more general term, which covers what a C compiler ... hardware-provided stack to implement the stack-like data structure ... manner since the current stack frame is "deformed" by alloca. ...
  • Re: Criticisms?
    ... VLAs give you more than just that one particular feature. ... For alloca() to be reliable, the compiler has to recognize calls ... problem is that each allocacall adjusts the stack while the ...
  • Re: alloca
    ... a compiler can decide to _always_ perform the calls to ... That's just another way to circumvent the potential problem with using 'alloca' in an argument list. ... A quality implementation might perform a run-time stack integrity check in debug configuration and trigger a run-time diagnostic. ... Although I don't direct connection to the 'alloca' being standard or not. ...
  • Re: FindFirstFile Possible Memory Leak
    ... Loop optimization and deeper parsers for ... for compiler variables that stack data is only ... stack pointer. ... function called alloca. ...
  • Re: FindFirstFile Possible Memory Leak
    ... for compiler variables that stack data is only ... function called alloca. ... This was suppose to allocate a local buffer on the stack and return its ... architectures, the stack pointer can be changed without losing your ...