Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site rlgvax.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!rlgvax!guy From: guy@rlgvax.UUCP (Guy Harris) Newsgroups: net.lang.c Subject: Re: Re: What is the setjump call Message-ID: <207@rlgvax.UUCP> Date: Thu, 18-Oct-84 18:13:22 EDT Article-I.D.: rlgvax.207 Posted: Thu Oct 18 18:13:22 1984 Date-Received: Sat, 20-Oct-84 06:51:00 EDT References: <2528@ihldt.UUCP> <169@rlgvax.UUCP>, <869@hou3c.UUCP> <4461@utzoo.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 29 > > Actually, the fact that longjmp works with one argument is not an > > accident. The SVR2 manual page for setjmp states, "If longjmp is > > invoked with a second argument of 0, setjmp will return 1." This > > was done to make the two argument version of setjmp backward com- > > patable with the one argument version. > > It's still an accident. Calling a function (e.g. longjmp) with fewer > parameters than expected is **NOT** guaranteed to make the missing > parameters look like zeros. This may work on some machines, but it > is not portable. Well, one could argue that if all one cares about is whether "setjmp" returns a 0 (normal return) or non-zero (nonlocal goto) value, then calling "longjmp" with only one argument will work under all circumstances (either the non-existent argument gets a zero value by accident, in which case it gets mapped into 1, or it gets a non-zero value by accident, in which case it is non-zero). However, it's still not guaranteed to work everywhere. (Admittedly, there are a few functions in the C library that take a variable number of arguments, like "printf" and the "open" system call in USDL UNIX and in 4.2BSD; however, whether the extra arguments are present or not can be intuited from the values of the required arguments, and the code can avoid touching the extra arguments if they are missing. This is emphatically not the case for "longjmp". There may be implementations of C in which not touching the missing arguments may not be enough; these implementations may special-case "printf", but not "setjmp" or "longjmp" - or "open", for that matter.) Guy Harris {seismo,ihnp4,allegra}!rlgvax!guy