To: J3 10-207r2 From: Bill Long/Craig Rasmussen/Robert Corbett Subject: Interop TR: Error for bad attribute in de/allocate Date: 2010 October 13 Reference: 10-165r2.pdf Discussion: Proposed at m192 was a requirement that the attribute value in a descriptor be for an allocatable or pointer object if the descriptor is supplied to CFI_allocate or CFI_deallocate. It is already required that the descriptor be for an allocatable or pointer object. Edits are provided to require that the value of the attribute member be valid, or the routine returns an error. Since we are now specifying that an error shall be detected for a specific case, it is no longer the case that which errors are detected is processor dependent. This paper supplies edits to identify specific error conditions that a processor might detect and macro names for the corresponding error codes. The list of error conditions is not intended to be exhaustive, but the error codes corresponding to other error conditions should be different from those specified below. If multiple error conditions could be detected, which error condition is detected is processor dependent. The macro CFI_SUCCESS is added for readability. Edits to 10-165r2: [11:1-] After Note 5.1 add "The macro CFI_SUCCESS shall be defined to be the integer constant 0. The values of the error codes returned for the error conditions listed below are named by the indicated macros. The macros shall be defined to be integer constant expressions suitable for use in #if preprocessing directives. The value of each macro shall be nonzero and shall be different from the values of the other macros specified in this section. Error conditions other than those listed in this section should be indicated by error codes different from the values of the macros named in this section. The error codes that indicate the following error conditions are named by the associated macro name. - the base address member of a C descriptor is NULL in a context that requires a non-null value CFI_ERROR_BASE_ADDR_NULL - the base address member of a C descriptor is not NULL in a context that requires a null value CFI_ERROR_BASE_ADDR_NOT_NULL - the value of the element length member of a C descriptor is not valid CFI_INVALID_ELEM_LEN - the value of the rank member of a C descriptor is not valid CFI_INVALID_RANK - the value of the type member of a C descriptor is not valid CFI_INVALID_TYPE - the value of the attribute member of a C descriptor is not valid CFI_INVALID_ATTRIBUTE - the value of the extent member of a CFI_dim_t structure is not valid CFI_INVALID_EXTENT - the value of the stride multiplier member of a CFI_dim_t structure is not valid CFI_INVALID_SM - the value of the upper bound member of a CFI_bounds_t structure is not valid CFI_INVALID_UPPER_BOUND - the value of the stride member of a CFI_bounds_t structure is not valid CFI_INVALID_STRIDE - a general error condition for C descriptors CFI_INVALID_DESCRIPTOR - memory allocation failed CFI_ERROR_MEM_ALLOCATION - a reference is out of bounds CFI_ERROR_OUT_OF_BOUNDS [11:9-12] In 5.2.6.1 Functions/General, replace "Each function ... processor dependent" with "Some of the functions described in 5.2.6 return an integer value that indicates if an error condition was detected. If no error condition was detected an integer zero is returned; if an error condition was detected, a nonzero integer is returned. A list of error conditions and macro names for the corresponding error codes is supplied in 5.2.5. A processor is permitted to detect other error conditions. If an invocation of a function defined in 5.2.6 could detect more than one error condition and an error condition is detected, which error condition is detected is processor dependent." [12:3-5] In 5.2.6.2 CFI_allocate, replace "On entry, ... data object." with "If the base address in the C descriptor is not NULL on entry, the C descriptor is not modified and CFI_ERROR_BASE_ADDR_NOT_NULL is returned. If the C descriptor is not for an allocatable or pointer data object, the C descriptor is not modified and CFI_INVALID_ATTRIBUTE is returned." [12:6] In 5.2.6.2 CFI_allocate, after "The stride values are ignored and assumed to be one." add "If a memory allocation failure is detected, the C descriptor is mot modified and CFI_ERROR_MEM_ALLOCATION is returned." [12:11-13] In 5.2.6.3 CFI_deallocate, replace "On entry, ... ALLOCATE statement." with "If the base address in the C descriptor is NULL on entry, the C descriptor is not modified and CFI_ERROR_BASE_ADDR_NULL is returned. If the C descriptor is not for an allocatable or pointer data object, the C descriptor is not modified and CFI_INVALID_ATTRIBUTE is returned."