public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Bug in setjmp/longjmp on Sparc
@ 2000-11-14  7:18 Richard Kenner
  0 siblings, 0 replies; only message in thread
From: Richard Kenner @ 2000-11-14  7:18 UTC (permalink / raw)
  To: gcc

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?

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2000-11-14  7:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-11-14  7:18 Bug in setjmp/longjmp on Sparc Richard Kenner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).