Path: utzoo!attcan!uunet!husc6!rutgers!ucsd!ucbvax!bloom-beacon!adam.pika.mit.edu!scs From: scs@adam.pika.mit.edu (Steve Summit) Newsgroups: comp.lang.c Subject: Re: Behaviour of setjmp/longjmp and registers Message-ID: <8867@bloom-beacon.MIT.EDU> Date: 21 Jan 89 06:37:15 GMT References: <25@torsqnt.UUCP> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: scs@adam.pika.mit.edu (Steve Summit) Lines: 28 Here are my rules for using setjmp/longjmp and remembering which variables are preserved: 1. Never use setjmp and longjmp. 2. If rule 1 must be broken, do not depend on the values of any variables after setjmp has "returned" due to a call to longjmp. These rules are admittedly conservative, but as long as I follow them I never have problems with setjmp or longjmp or which variables are preserved. I believe I have broken rule 1 twice; I have had problems with variable preservation approximately 50% of those times. Therefore I conclude that rule 1 is a good rule. Steve Summit scs@adam.pika.mit.edu Ten people will now sanctimoniously flame me, saying that the problem is not with setjmp/longjmp but with my (lack of) understanding of them. Save it. I could remember the details and rationale of the variable preservation rules if I wanted to. Since I consider longjmp an abysmal idea in the first place, and I have been able to get along without it virtually all of the time, I don't choose to keep my knowledge on it current. It is also unnecessary to point out to me all of the cases where longjmp has been found indispensable; I'm familiar with the arguments.