Behaviour of setjmp/longjmp and registers
David Haynes
david at torsqnt.UUCP
Fri Jan 20 13:30:14 AEST 1989
What should be the result of running the following program?
#include <setjmp.h>
main()
{
register int j;
jmp_buf env;
j = 1;
if(setjmp(env) == 1) {
printf("j = %d\n", j);
exit(1);
}
printf("j = %d\n", j);
j += 3;
longjmp(env, 1);
}
Sequent, Ultrix and Vax C give results of j = 1, j = 4.
Gcc gives a result of j = 1, j = 1.
What does the ANSI standard say about this?
-david-
More information about the Comp.lang.c
mailing list