J3/09-244 To: J3 From: Van Snyder Subject: Problems with RETURN and completion of a procedure Date: 2009 June 30 References: 09-007r2, 09-224r3, 09-176r1, 09-109, 08-206 1. Introduction The discussion of automatic deallocation in 6.7.3.2p2 says that automatic deallocation occurs "when the execution of a procedure is terminated." But automatic deallocation is certainly not part of execution of the calling scoping unit, so it must be part of the called procedure. So it can't happen after execution of the procedure is terminated. It has to be done when a RETURN or END statement is executed, but before execution of the procedure is terminated. The description of RETURN is incorrect in the same respect. We also don't want automatic deallocation to occur before finalization, or pointers and variables to become undefined before finalization and automatic deallocation take place. 2. Edits w.r.t. 09-007r2 [130:23 6.7.3.2p2]------------------------------------------------------ Editor: Replace "When ... statement" by "When a RETURN or END statement is executed (12.6.2.7)". {This gives a precise place to look instead of hunting through clause 12.} [311:41 12.6.2.7p1]----------------------------------------------------- Editor: Replace "completes" in the first sentence of the paragraph by "initiates completion of". Add a sentence after the first one: "When a RETURN statement is executed, finalization occurs as described in 4.5.6.2, followed by deallocation of allocatable variables as described in 6.7.3.2, followed by undefinition of pointers and variables as described in 16.5.2.4 and 16.6.6." [312:3 12.6.2.7p1]------------------------------------------------------ Add a sentence at the end of the paragraph: "\obs{If a branch to an alternate return does not occur,} the normal execution sequence is resumed in the invoking scoping unit."