Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Behaviour of setjmp/longjmp and registers Message-ID: <1989Jan20.173052.7051@utzoo.uucp> Organization: U of Toronto Zoology References: <25@torsqnt.UUCP> Date: Fri, 20 Jan 89 17:30:52 GMT In article <25@torsqnt.UUCP> david@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@zoo.toronto.edu