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]

Further observations regarding alloca on i586-pc-linux-gnu


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.

-- 
Regards
       Joerg
GMD-IPSI, Dolivostr. 15, Zimmer 120, D-64293 Darmstadt
+49-6151-869-786 (Phone), -818 (FAX)


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