Behaviour of setjmp/longjmp and registers

Chris Torek chris at mimsy.UUCP
Tue Jan 24 19:13:32 AEST 1989


In article <7249 at polyslo.CalPoly.EDU> cquenel at polyslo.CalPoly.EDU
(101 more school days) writes:
>I see [making registers work as well as automatics around setjmp/longjmp]
>as a BAD thing to try to guarantee.

and bases this argument on the idea that `register' is a compiler hint
and need not actually use a machine register.

>As a compiler writer, it certainly makes sense to me to only implement
>what can be guaranteed. ...

But the contents of *all* automatic variables (register or not) *can* be
guaranteed without too much trouble, and without requiring `volatile'
qualifiers.

If you will accept as the definition of a `very good' compiler `one that
does interprocedural analysis and register allocation', then a good compiler
must (since it may allocate registers to variables that are not automatic)
make guarantees that will stand up for automatic variables even in the
presence of longjmp, and the problem vanishes entirely.  So a very good
compiler will make such guarantees.  Other compilers could simply turn
off optimisation in functions containing calls to setjmp().

>I think this newer definition of setjmp/longjmp is much cleaner
>and provides only what is necessary and most useful.

This is a separate (and much more sensible) line of argument with
which I happen not to agree: opinion as to elegance.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list