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


Joerg Pommnitz <pommnitz@darmstadt.gmd.de> writes:

> While the following code dies with a segmentation violation

> #include <cstdlib>
> #include <iostream>
> class xx { public: char *xy (char *c = alloca (18)) {
>                 strcpy (c, "Hello World!"); return c; } };
> int main () { xx x; cout << x.xy () << endl; }

> Is this a bug? I think yes, but I'm not sure whether case #1
> is supposed to work.

IMO, it should work on x86, as it does on sparc and alpha.  The
problem is that the stack pointer is moved after pushing default
arguments onto the stack.

Unfortunately, I don't have the (time required to develop) skills
needed to fix it, so I'll leave this for someone else.

Anyway, next time you report a problem, please clearly state on which
platform you have encountered it, and which compiler options you have
used.  It took me some time to find out the problem would only occur
on x86 without optimization!

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil



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