Article View: comp.std.c
Article #5950Re: setjmp/longjmp
From: Anton Rang
Date: Thu, 27 Apr 1989 20:23
Date: Thu, 27 Apr 1989 20:23
26 lines
2039 bytes
2039 bytes
In article <1447@cunixc.cc.columbia.edu> fuat@cunixc.cc.columbia.edu (Fuat C. Baran) writes:
We just got an Encore Multimax running UMAX 4.2 (equivalent to BSD
4.2). While bringing up one of our software packages we ran into a
strange problem with setjmp/longjmp. The code is setting a flag
(declared int in main()) and then doing a setjmp. It would then check
this flag and if true, set the flag to false and call a function which
would longjmp.
[ story about it not working and searching the manual ]
All acces-
] sible data have values as of the time longjmp was called except for
] objects of automatic storage class that have been changed between the
] setjmp and longjmp calls. The values of these objects is indeterminate
] (this behavior conforms to the Draft ANSI C language standard).
This happens with automatic variables which are allocated in registers. The
setjmp/longjmp code may not save and restore these registers; in this case,
their values will be lost. In some compilers, you can use 'volatile' to
avoid this; otherwise, declaring variables as 'static' may help (or making
them 'static volatile' maybe?).
+---------------------------+------------------------+---------------------+
| Anton Rang (grad student) | "VMS Forever!" | rec.music.newage is |
| Michigan State University | rang@cpswh.cps.msu.edu | under discussion... |
+---------------------------+------------------------+---------------------+
Technical Details
Message-ID:
<2760@cps3xx.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!ames!ncar!tank!eecae!cps3xx!rangReferences:
<1447@cunixc.cc.columbia.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!ames!ncar!tank!eecae!cps3xx!rang From: rang@cpsin3.cps.msu.edu (Anton Rang) Newsgroups: comp.std.c,comp.sys.encore Subject: Re: setjmp/longjmp Message-ID: <2760@cps3xx.UUCP> Date: 27 Apr 89 20:23:30 GMT References: <1447@cunixc.cc.columbia.edu> Sender: usenet@cps3xx.UUCP Reply-To: rang@cpswh.cps.msu.edu (Anton Rang) Organization: Michigan State University, Computer Science Dept. Lines: 26 In-reply-to: fuat@cunixc.cc.columbia.edu's message of 27 Apr 89 03:42:32 GMT