This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Further observations regarding alloca on i586-pc-linux-gnu
- To: Joerg Pommnitz <pommnitz at darmstadt dot gmd dot de>
- Subject: Re: Further observations regarding alloca on i586-pc-linux-gnu
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 21 Aug 1998 14:57:35 -0300
- Cc: egcs at cygnus dot com
- References: <35DC18E0.72A3D09E@darmstadt.gmd.de>
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