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: Noel Yap <nyap at garban dot com>
- Date: Fri, 21 Aug 1998 07:36:43 -0400
- CC: egcs at cygnus dot com
- Organization: Garban LLC
- References: <35DC18E0.72A3D09E@darmstadt.gmd.de>
Joerg Pommnitz wrote:
>
> 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;
> }
> ---
>
> this one works fine:
>
> #include <cstdlib>
> #include <iostream>
>
> class xx {
> public:
> char *xy (char *c = alloca (18)) {
> strcpy (c, "Hello World!");
> return c;
> }
> };
>
> int
> main ()
> {
> xx x;
> char *c = alloca (18);
>
> cout << x.xy (c) << endl;
> }
>
> Is this a bug? I think yes, but I'm not sure whether case #1
> is supposed to work. Since alloca is a compiler builtin
> function this relates to egcs development and should either be
> fixed or documented.
Whose stack does will xy's alloca() call execute in? It should _not_
be executed in main() regardless of whether xy() is inlined or not.
Function behaviour should not change based on its inline status,
otherwise different inlining heuristics would produce different
executables.
Noel