To: J3 J3/21-102r2 From: R. Bader & Bill Long Subject: CFI_setpointer interpretation request F18/024 Date: 2021-March-05 Reference: 18-007r1 ---------------------------------------------------------------------- NUMBER: F18/024 TITLE: CFI_setpointer with result a deferred length character KEYWORDS: C interoperability DEFECT TYPE: Erratum STATUS: Submitted QUESTION: Is the requirement in CFI_setpointer that the elem_lem member have the same value in the source and result arguments intended to apply if the result is of type CHARACTER with the length parameter deferred? ANSWER: No. It is an oversight in the standard that this rule apply to the case of result being of type CHARACTER and having the length parameter deferred. Currently in section 18.5.5.9 "The CFI_setpointer function" states in para 2 that "If source is not a null pointer, the corresponding values of the elem_len, rank, and type members shall be the same in the C descriptors with the addresses source and result." The function can therefore not work correctly if the "result" parameter is a descriptor address for a deferred-length character entity coming in from Fortran, because the elem_len value is not available. Manual updates to result->elem_len are prohibited by 18.6 para 1. The CFI_setpointer function in the intrinsic module ISO_C_BINDING is intended to provide a means for C programmers to replicate the pointer association capability in Fortran, for dummy arguments in interfaces with with interoperable interfaces. Thus, for the case of a character result having deferred length, which is allowed at [478:21], the correct action should be for the elem_len value from the source to be copied to the same member of result as part of execution of the function. Edits are supplied to correct this defect. EDITS to 18-007r1: In 18.5.5.9 The CFI_setpointer function - [491:27] In the description of the source formal parameter, second sentence, delete "elem_len, ". - [491:28+] In the description of the source formal parameter, after the second sentence add new sentence: "If source is not a null pointer and the C descriptor with the address result does not describe a deferred length character pointer, the corresponding values of the elem_len member shall be the same in the C descriptors with the addresses source and result." - [491:31] In the first sentence of paragraph 3, "Description" replace "base_addr and dim" by "base_addr, dim and possibly elem_len". - [491:38] At the end of the second bullet point of paragraph 3, "Description", add new sentence; "If the C descriptor with the address result describes a character pointer of deferred length, the value of its elem_len member is set to source->elem_len". SUBMITTED BY: Reinhold Bader HISTORY: 21-102r1 m223 F18/024 Submitted 21-102r3 m233 Paper passed. ----------------------------------------------------------------------