home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / unix / internal / 2107 < prev    next >
Encoding:
Internet Message Format  |  1993-01-10  |  1.5 KB

  1. Path: sparky!uunet!cs.utexas.edu!asuvax!chnews!sedona!bhoughto
  2. From: bhoughto@sedona.intel.com (Blair P. Houghton)
  3. Newsgroups: comp.unix.internals
  4. Subject: Re: Question about longjmp ()
  5. Date: 10 Jan 1993 23:05:17 GMT
  6. Organization: Intel Corp., Chandler, Arizona
  7. Lines: 25
  8. Message-ID: <1iqa3dINNb96@chnews.intel.com>
  9. References: <C0JpMo.1rGr@austin.ibm.com> <1993Jan10.145640.3647@sequent.com> <184875@pyramid.pyramid.com>
  10. NNTP-Posting-Host: stealth.intel.com
  11.  
  12. In article <184875@pyramid.pyramid.com> jmuth@pyrps5.eng.pyramid.com (John Muth) writes:
  13. >I'm not sure what the C langauge spec. says about the semantics of this sort
  14. >of construct or even if it addresses it at all. After all, K&R left lots of 
  15. >things like this up to the imagination of the complier writer.
  16.  
  17. The standard (ANSI X3.159-1989) says, after much waving of
  18. hands and servicing of lips, that the value of `i' in this
  19. program is "indeterminate" after the call to longjmp (because
  20. it's an auto variable changed between the calls etc. etc.).
  21.  
  22. >My suggestion to the original poster is "don't do that". Setjmp defines
  23. >a return value in order to avoid this situation. Use it.
  24.  
  25. Um, yes, theoretically you can save `i' by passing it back
  26. through longjmp, but you only get to do that to one
  27. variable.
  28.  
  29. The real value of setjmp/longjmp is that it restores the
  30. signal mask and can pull you out of a deep recursion if a
  31. minor occurrence results in a rare and complicated
  32. problem.  You shouldn't use it as part of handling
  33. predictable errors; then it'd be just another `goto'.
  34.  
  35.                 --Blair
  36.                   "etc., etc..."
  37.