Behaviour of setjmp/longjmp and registers
Henry Spencer
henry at utzoo.uucp
Sat Jan 21 03:30:52 AEST 1989
In article <25 at torsqnt.UUCP> david at torsqnt.UUCP (David Haynes) writes:
>What does the ANSI standard say about this?
If function foo() calls setjmp(), and then it or a function called by
it calls longjmp(), the values of any local variables which are not
volatile and which have changed since the setjmp() are *indeterminate*.
Your program could give j = 1, j = 666 if the implementor felt like it.
Note, this behavior is *not* limited to variables declared "register".
In practice, it is highly likely that any self-respecting implementation
will restrict this nasty behavior to variables declared "register", or
even eliminate it entirely. (Some of us thought that it was both feasible
and important to require one of these two approaches, in fact, but X3J11
did not agree.) It is also highly likely that the value will not in
fact be random, but will be either the value as of setjmp() time or the
value as of longjmp() time. However, strictly conforming programs cannot
rely on any of this.
--
Allegedly heard aboard Mir: "A | Henry Spencer at U of Toronto Zoology
toast to comrade Van Allen!!" | uunet!attcan!utzoo!henry henry at zoo.toronto.edu
More information about the Comp.lang.c
mailing list