Re: [AD] 4.3 error handling

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2006-06-08, Chris <chris.kcat@xxxxxxxxxx> wrote:
> On Thursday 08 June 2006 18:12, Peter Wang wrote:
> > Found this in the info manual:
> >
> >    When you perform a non-local exit, accessible objects generally
> > retain whatever values they had at the time `longjmp' was called.  The
> > exception is that the values of automatic variables local to the
> > function containing the `setjmp' call that have been changed since the
> > call to `setjmp' are indeterminate, unless you have declared them
> > `volatile'.
> 
> Non-static local variables are supposed to be on the stack, aren't they? 

No, local variables can be in registers.

> According to the man page:
> 
> setjmp() saves the stack context/environment in env for later use by 
> longjmp(). The stack context will be invalidated if the function which called 
> setjmp() returns.
> 
> Which sounds to me like the local variables will be preserved /as long as/ the 
> function that called setjmp doesn't return.. and since you don't prematurely 
> exit a try block, and the end of the try block automatically clears the last 
> setjmp point, this can't happen.

I think what they're trying to say is that the stack frame will have at
least a return address that points to the previous stack frame.  Once
you return from the function you called setjmp from, that address could
be pointing to pretty much anything.

Peter





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/