This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: gcc 2.95.2 problem: alloca done within argument list evaluation, corrupts the rest of the argument list
- To: etienne dot lorrain at ibm dot net
- Subject: Re: gcc 2.95.2 problem: alloca done within argument list evaluation, corrupts the rest of the argument list
- From: Alexandre Oliva <oliva at lsd dot ic dot unicamp dot br>
- Date: 13 Jan 2000 16:55:42 -0200
- Cc: gcc-bugs at gcc dot gnu dot org
- References: <20000112134542.29049.qmail@web1903.mail.yahoo.com>
On Jan 12, 2000, Etienne LORRAIN <etienne_lorrain@yahoo.fr> wrote:
>> f (yyy((t1 = alloca(ALLOCA_SIZE),xxx(t1))), 2);
^ matches ^
> undefined behavior: t1 is used and changed without
> resynchronisation point in between.
But there is a sequence point. t1=alloca(...) and xxx(t1) are
arguments or a function call, they form a single expression by means
of the comma operator.
> Because in C, parameters are pushed from right to left,
That's not true in general. In fact, there's no such thing as
`push'ing arguments in C. But, on x86, it's true, arguments are
usually evaluated from right to left, because arguments are passed on
the stack. But you already knew that :-)
Anyway, this operation does indeed invoke undefined behavior, given
that alloca is not part of the C standard. In any case, it can't
(shouldn't?) generally be called within complex expressions involving
other function calls, since, on some architectures (such as x86),
function calling involves stack operations, and so does alloca.
--
Alexandre Oliva http://www.ic.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{lsd.ic.unicamp.br,guarana.{org,com}} aoliva@{acm,computer}.org
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them