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]

Re: Further observations regarding alloca on i586-pc-linux-gnu


Martin von Loewis wrote:
> 
> > I really think the test is valid. There are no documented
> > constraints on the usage of alloca.
> 
> This is a weak point :-) There is no alloca documentation, period.
> It's not an ANSI C or ISO C++ function, so you code is certainly not
> valid standard C++.
> 

I know it is not ISO C++, however it would be very convenient. Without
alloca there are basically three ways to return a pointer:

a) allocate heap memory inside the function. Disadvantage: needs
   explicite release.
b) return a pointer to static memory. Disadvantage: not thread safe
   and code like
   a (xx(), xx();
   can give unexpected results.
c) pass a local array. closest to alloca, but requires more typing.

> > An option "-fno-inline-alloca" and the generic alloca emulation
> > included in glibc would provide a useable work around.
> 
> Well, this is easy to provide. Please check out -fno-builtin. Be aware
> of alloca.h, which just knows we support __builtin_alloca.
> 

Will do. Does it kill every built in function or is it possible to
target
a specific one?

> Regards,
> Martin

Regards
	Joerg


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