Ambiguity in definition of setjmp/longjmp makes them much less useful

Rodney Radford sasrer at unx.sas.com
Wed Oct 10 00:35:21 AEST 1990


In article <1597 at redsox.bsw.com> campbell at redsox.bsw.com (Larry Campbell) writes:
>My real question is this:  Why not define the behavior of setjmp/longjmp so
>that the values of ALL local variables are defined, whether or not they've
>been allocated to registers?  Otherwise, setjmp/longjmp are significantly
>less useful.

The reason for the ambiguity is because ANSI chose not to make setjmp/longjmp
functions known by the C compiler so that it just treats them just like any
other functions (ie: does not force local automatics values from registers
to storage). ANSI chose not to make any of the functions special case so
that an application may redefine the functions (although this is frowned upon
in some cases). The setjmp/longjmp functions themselves do not have the
required information to force the values from the registers, so we are stuck
with this oddity.

>
>For what it's worth, it seems to me that the description of setjmp/longjmp in
>K&R 2 does imply that x should have the value 1; is this an area of
>disagreement between K&R and ANSI?

I believe (just guessing really) that the original C used 'builtins' for the
setjmp/longjmp functions, ie: they special cased them.

>-- 
>Larry Campbell                          The Boston Software Works, Inc.
>campbell at redsox.bsw.com                 120 Fulton Street
>wjh12!redsox!campbell                   Boston, MA 02109


-- 
Rodney Radford        DG/UX AViiON developer        SAS Institute, Inc.
sasrer at unx.sas.com    (919) 677-8000 x7703          Box 8000, Cary, NC 27512



More information about the Comp.lang.c mailing list