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]

Using alloca (or stmt exprs) as a function call argument is bad?


I seem to recall its not portable to use alloca as an argument to a
function call.  E.g.
 > #define strdupa(X) strcpy(alloca(strlen(X)+1),(X))

This is true even if you're only talking about gcc, let alone other
compilers, right?  And its presumably because alloca is diddling with
the stack at the same time function parameters are being pushed there?

What about statement expressions?  E.g.
 > #define foo(X) ({int bar = X; bar*bar+3;})
 > baz(foo(3), foo(7))

Does that pose any stack problems on any target?

If either is a bad idea, I suggest we issue a warning when the user
attempts it.  I've seen cases in gcc source where at least the former
is done.  I'm willing to give it a try if someone can point very
specifically where it should go.

		--Kaveh
--
Kaveh R. Ghazi			Engagement Manager / Project Services
ghazi@caip.rutgers.edu		Qwest Internet Solutions


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