[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #63268] throw|catch behavior: unexpected items at data stack

From: Anton Ertl
Subject: [bug #63268] throw|catch behavior: unexpected items at data stack
Date: Tue, 25 Oct 2022 03:19:36 -0400 (EDT)

Update of bug #63268 (project gforth):

                Severity:              3 - Normal => 1 - Wish               
                  Status:                    None => Invalid                
             Open/Closed:                    Open => Closed                 


Follow-up Comment #3:

Yes.  The depth effect is intended, and the values of stack items "pushed" by
throw are arbitrary (apart from the ball).

The idea behind this is that the code that throws does in general not know the
place that catches the throw, and does not know the stack depth in case of a
non-throwing exit.  So it restores the stack depth to the depth on entry to
the CATCH (or at the TRY), and the code after CATCH can then deal with the
situation (it knows from the ball whether there was a non-throwing exit or a
throwing exit).

How do you know which values on the stack may be nonsense? From the stack
effect of the xt passed to catch (or the code between TRY and RESTORE).  If
the stack effect is ( n1 n2 -- n3 n4 ), you know that the code can have taken
n1 and n2 off the stack before throwing, so these two cells are arbitrary.


Reply to this item at:


Message sent via Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]