about summary refs log tree commit diff
path: root/setjmp
diff options
context:
space:
mode:
Diffstat (limited to 'setjmp')
-rw-r--r--setjmp/Makefile2
-rw-r--r--setjmp/jmpbug.c32
2 files changed, 33 insertions, 1 deletions
diff --git a/setjmp/Makefile b/setjmp/Makefile
index 4773b617e1..3d004852c8 100644
--- a/setjmp/Makefile
+++ b/setjmp/Makefile
@@ -26,7 +26,7 @@ headers	:= setjmp.h jmp_buf.h
 routines	:= setjmp sigjmp bsd-setjmp bsd-_setjmp \
 		   longjmp __longjmp jmp-unwind
 
-tests		:= tst-setjmp
+tests		:= tst-setjmp jmpbug
 
 
 include ../Rules
diff --git a/setjmp/jmpbug.c b/setjmp/jmpbug.c
new file mode 100644
index 0000000000..57a1de0978
--- /dev/null
+++ b/setjmp/jmpbug.c
@@ -0,0 +1,32 @@
+/* setjmp vs alloca test case.  Exercised bug on sparc.  */
+
+#include <stdio.h>
+#include <setjmp.h>
+#include <alloca.h>
+
+void
+sub5 (jmp_buf buf)
+{
+  longjmp (buf, 1);
+}
+
+int
+main (void)
+{
+  jmp_buf buf;
+  char *foo;
+  int arr[100];
+
+  arr[77] = 76;
+  if (setjmp (buf))
+    {
+      printf ("made it ok; %d\n", arr[77]);
+      exit (0);
+    }
+
+  foo = (char *) alloca (128);
+  sub5 (buf);
+
+  /* NOTREACHED */
+  return 1;
+}