Should this work?
Joerg Pommnitz
pommnitz@darmstadt.gmd.de
Wed Aug 19 15:29:00 GMT 1998
I get a SEGV with the following program under i586-pc-linux-gnu:
#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;
}
The idea is to use alloca to allocate memory from the callerôs
stack and to be able to do something like:
printf ("%s %s", x.xy (), x.xy ());
without having to clean up.
Regards
Joerg
More information about the Gcc
mailing list