Newsgroups: | comp.compilers |
From: | henry@zoo.toronto.edu (Henry Spencer) |
Organization: | U of Toronto Zoology |
Date: | Thu, 23 Jul 1992 17:03:03 GMT |
Keywords: | C, optimize |
References: | 92-07-064 92-07-073 |
shankar@sgi.com (Shankar Unni) writes:
>This is totally bogus. Let us assume that the ANSI spec were to say: local
>variables are guaranteed to retain their values when a longjmp() takes you
>back to the stack.
>
>Now how would this be done on a machine with several registers ...
The right way to do it is to have the compiler recognize the presence of
setjmp() -- ANSI C carefully restricts setjmp() usage so this is
guaranteed to be possible -- and take suitable precautions.
That is a little tricky in a simple one-pass compiler. What such a
compiler can do, however, is note the presence of the <setjmp.h> header,
and take worst-case precautions for code compiled with that header
visible.
Historical practice is to say that variables marked "register" can lose
their values, and others can't. Any compiler smart enough to silently
promote variables into registers ought to be able to handle one of the
above strategies.
And yes, some of us said these things to X3J11, but they didn't listen...
--
Henry Spencer @ U of Toronto Zoology, henry@zoo.toronto.edu utzoo!henry
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.