This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Bug in setjmp/longjmp on Sparc
- To: gcc at gcc dot gnu dot org
- Subject: Bug in setjmp/longjmp on Sparc
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- Date: Tue, 14 Nov 00 10:17:56 EST
Try running the following test case:
int buf[20];
void
main ()
{
char *p = (char *) alloca (20);
strcpy (p, "test\n");
if (__builtin_setjmp (buf))
{
printf (p);
exit (0);
}
{
int *q = (int *) alloca (p[2] * sizeof (int));
int i;
for (i = 0; i < p[2]; i++)
q[i] = 0;
while (1)
sub2 ();
}
}
sub2 ()
{
__builtin_longjmp (buf, 1);
}
This will dump core on Solaris. The reason is that the SP saved in the setjmp
buffer is expected to be the location where the registers will be saved, but
instead they are saved at the value of SP at the call.
Does anybody who knows the Sparc better than I do have any suggestions
as to how to fix this?