J3/05-239 Date: July 25, 2005 To: J3 From: Aleksandar Donev Title: Storage units and STORAGE_SIZE inquiry function References: J3 proposal J3-004 in WG5 Repository Basic Functionality: Modify the original STORAGE_SIZE proposal to allow for arguments that are 1) Of arbitrary declared derived type, and 2) Polymorphic, including unlimited polymorphic To do this some extension to 16.4.3.1 will need to be done in order to explain what a storage unit means in such contexts. The procedure STORAGE_SIZE is in ISO_FORTRAN_ENV and returns the size in bits of the storage unit for a scalar with the same type as the *dynamic* type of its argument, as specified in 16.4.3.1. Without the proposed modification, I believe the utility of this function is too small and covers only a small subset of existing demand. Rationale: There are situations where a program needs to know the size of an entity. Estimated Impact: Many vendors already provide extensions similar to this. The standard will hopefully be impacted in a minimal way localized in 16.4.3. Detailed Specification: It seems some addition to 16.4.3.1 is necessary in order to clarify the concept of a storage unit in certain cases. The problem at present seems to be the leading "In a storage association context" before the numbered list in 16.4.3.1 [from private discussion with Richard]. This wording excludes things like polymorphic objects as such cannot occur in a storage association context. This wording is likely there in order to clarify things like the fact that holding a variable in register does not give it a different storage unit. I ask J3 to consider the issue and come up with a recommendation. Here is the original spec for STORAGE_SIZE: __________________________________ *Description.* Returns the storage size in bits for a nonpointer nonallocatable scalar of the declared type of X. *Class.* Inquiry function. *Arguments.* X may be of intrinsic or derived type. It shall not be polymorphic. If it is of derived type, that type shall be a SEQUENCE or interoperable type and shall have no allocatable ultimate components. If its type has any deferred type parameters, it shall be a pointer that is associated or an allocatable object that is allocated. It may be a scalar or an array. *Result Value.* The result value is the size in bits of the storage unit (16.4.3.1) in a storage association context for a nonpointer nonallocatable scalar with the declared type and type parameters of X. __________________________________ The modification should be: __________________________________ *Description.* Returns the storage size in bits for a nonpointer nonallocatable scalar of the dynamic type of X. *Arguments.* X may be of intrinsic or derived type, and it may be polymorphic. It may be a scalar or an array. If it is pointer or allocatable and it is polymorphic or its type has any deferred type parameters, it shall be a pointer that is associated or an allocatable object that is allocated. *Result Value.* The result value is the size in bits of the storage unit (16.4.3.1) in a storage association context for a nonpointer nonallocatable scalar with a declared type and type parameters that are the same as the dynamic type of X. __________________________________ History: J3/05-239 at meeting 173 ------------------------------------------------------------------