jmpbug.c 513 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* setjmp vs alloca test case. Exercised bug on sparc. */
  2. #include <stdio.h>
  3. #include <setjmp.h>
  4. #include <alloca.h>
  5. static void
  6. sub5 (jmp_buf buf)
  7. {
  8. longjmp (buf, 1);
  9. }
  10. static void
  11. test (int x)
  12. {
  13. jmp_buf buf;
  14. char *volatile foo;
  15. int arr[100];
  16. arr[77] = x;
  17. if (setjmp (buf))
  18. {
  19. printf ("made it ok; %d\n", arr[77]);
  20. return;
  21. }
  22. foo = (char *) alloca (128);
  23. (void) foo;
  24. sub5 (buf);
  25. }
  26. int
  27. main (void)
  28. {
  29. int i;
  30. for (i = 123; i < 345; ++i)
  31. test (i);
  32. return 0;
  33. }