Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!gatech!hao!murphy From: murphy@hao.UCAR.EDU (Graham Murphy) Newsgroups: comp.os.vms Subject: Re: setjmp and longjmp in VAX-C Message-ID: <680@hao.UCAR.EDU> Date: Mon, 25-May-87 12:18:22 EDT Article-I.D.: hao.680 Posted: Mon May 25 12:18:22 1987 Date-Received: Tue, 26-May-87 01:45:04 EDT References: <121@acad.UUCP> Reply-To: murphy@hao.UUCP (Graham Murphy) Organization: High Altitude Obs./NCAR, Boulder CO Lines: 31 Keywords: setjmp longjmp VAX-C Summary: Beware automatic variables In article <121@acad.UUCP> robert@acad.UUCP (Robert Wenig ext 609) writes: > >I have found that setjmp does not work correctly if the module in which >the call was contained was compiled with OPTIMIZE on. Has anyone else >encountered similar problems? > > >Robert Wenig >Autodesk I assume by "does not work" you have found that some variables don't retain their expected values when you return to the routine. This is because the longjmp restores ALL the registers, which means any variables that have been optimized into these registers will take on the values they had when the setjmp call was made. Can be tricky as it is not always obvious when this will happen (except with hindsight.) In all other respects I have had no problems with setjmp/longjmp having used it in many optimized routines. Graham Murphy High Altitude Observatory National Center for Atmospheric Research -- UUCP: {hplabs, seismo, nbires, noao}!hao!murphy CSNET: murphy@ncar.csnet ARPA: murphy%ncar@CSNET-RELAY.ARPA INTERNET: murphy@hao.ucar.edu NOT-NET: P.O. Box 3000, Boulder, CO 80307-3000. (303) 497-1514.