Further observations regarding alloca on i586-pc-linux-gnu
Alexandre Oliva
oliva@dcc.unicamp.br
Fri Aug 21 16:30:00 GMT 1998
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
More information about the Gcc
mailing list