Behaviour of setjmp/longjmp and registers
David F. Carlson
dave at micropen
Tue Jan 24 04:59:05 AEST 1989
In article <25 at torsqnt.UUCP>, david at torsqnt.UUCP (David Haynes) writes:
> What should be the result of running the following program?
> register int j;
> jmp_buf env;
>
> 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?
>
According to SVr3.0 setjmp(3):
BUGS: The values of the registers on the second return from setjmp
are the register values at the time of the first call to setjmp, not
those at the time longjmp.
This doesn't answer the ANSI question per se, but it does point out that
using register variables around setjmp/longjmp is a fool's game. Play
it safe, use a condom.
--
David F. Carlson, Micropen, Inc.
micropen!dave at ee.rochester.edu
"The faster I go, the behinder I get." --Lewis Carroll
More information about the Comp.lang.c
mailing list