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]

Bug in setjmp/longjmp on Sparc


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?

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