J3/02-304r1 Date: November 13, 2002 To: J3 From: Rob James Subject: Allocatable result variables and ENTRY Introduction ------------ The following code seems to be allowed when it probably shouldn't be: FUNCTION foo() INTEGER, ALLOCATABLE :: foo INTEGER :: bar ... ENTRY bar() ... END FUNCTION Page 279, lines 18-22 of the Committee Draft state: If the characteristics of the result of the function named in the ENTRY statement are the same as the characteristics of the result of the function named in the FUNCTION statement, their result variables identify the same variable, although their names need not be the same. Otherwise, they are storage associated and shall be scalars without the POINTER attribute and one of the types: default integer, default real, double precision real, default complex, or default logical. The code above fits into the "otherwise" situation. So, they must be scalars (yes, they are) without the POINTER attribute (no POINTER attribute here), and one of the types mentioned (default integer is in the list). Both foo and bar fit those criteria and are storage associated. But, for foo, what storage are we talking about? Certainly not the dope vector. Does it mean that the storage allocated for foo needs to be the same as the storage for bar? Does it mean that they can be separate, but need to be kept synchronized with each other (i.e. the same value at all times)? All of these suggestions are terrible. And besides, wasn't this the reason behind prohibiting the POINTER attribute in this situation? The only acceptable solution is to prevent these function results from having the ALLOCATABLE attribute as well as the POINTER attribute. Proposed Edits -------------- Page and line numbers refer to the Committee Draft. [279:20-22] The sentence beginning with "Otherwise" doesn't parse well as it is, and simply adding "or ALLOCATABLE" would make the problem worse. So, I propose changing this sentence to the following: Otherwise, they are storage associated and shall all be nonpointer, nonallocatable scalars of type default integer, default real, double precision real, default complex, or default logical.