This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: alloca + inline



On Sun, 16 Mar 2003, Robert Dewar wrote:

> 
> Certainly I agree that the most natural option is 4), which is that the
> storage should always be reclaimed regardless of whether the function is
> inlined. I agree that it seems a bug if this is not the case, given the
> clear language that describes alloca.
> 

Ok, but I think the bug will always exist as long as:

 - an inline function is as fast as a macro

and

 - always_inline is always obeyed


IMHO, it would be better to make this a gcc extension and
say "This temporary space is automatically freed on return
of the first not-inlined caller".

Then, people will know that they're doing without assumptions.

Those who don't want the effect will either not inline
the function or avoid using alloca. If somebody, now uses
always_inline+alloca in a loop (like the geoffk example)
they're screwed.

So it seems that the right thing is either:

 - Make this a gcc extension.
 - Reclaim the stack for inlines that call alloca
   (and say that an inline is not as fast as a macro
    if it calls alloca)
 - Forbid inlining and disobey always_inline (and then
    add a new always_definatelly_inline attribute:)


Finally, the language that describes alloca is exceptional
anyway: alloca can't be called in function arguments.
alloca is a hack.





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]