Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!cme!libes From: libes@cme.nist.gov (Don Libes) Newsgroups: comp.std.c Subject: why does setjmp return 1 after longjmp(buf,0)? Message-ID: <6511@muffin.cme.nist.gov> Date: 15 Sep 90 17:07:26 GMT Reply-To: libes@cme.nist.gov (Don Libes) Organization: National Institute of Standards and Technology Lines: 27 After being bitten by this, I thought about it awhile and I still find it odd. "Portability and the C Language" [Jaeschke] says this is: "so that a call to setjmp directly (which returns 0) cannot be confused with longjmp's returning through setjmp with a value of 0." I think it's more confusing this way. If a programmer doesn't want to be confused with setjmp's original call, then isn't the obvious solution to choose a different value than 0? Why would someone explicitly say longjmp(buf,0) rather than longjmp(buf,1)? It surely can't be for readability! Has any of you personally ever intentionally written longjmp(buf,0) knowing that it would return 1? Or did this become Standard because of "existing practice" and the thought that it would break working programs? (I suspect it would probably fix more programs.) Was there any discussion about "fixing" this? I have some old UNIX manuals that document setjmp returning whatever longjmp says, no questions asked. When did this "feature" creep in? Don Libes libes@cme.nist.gov ...!uunet!cme-durer!libes Oh, and as long as I'm getting my burning questions answered, what does PJ stand for?