To: J3 J3/21-102 From: R. Bader Subject: CFI_setpointer interpretation request Date: 2021-January-23 Reference: 18-007r1 1. Description of the issue ~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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 values will typically mismatch. Manual updates to result->elem_len are prohibited by 18.6 para 1. Since within Fortran CHARACTER(len=4), TARGET :: source CHARACTER(len=:), POINTER :: result result => source will work just fine, this surely is a defect in the current specification. 2. Suggested resolution ~~~~~~~~~~~~~~~~~~~~~~~ For the case of a character result pointer in a call to CFI_setpointer, - permit result->elem_len having a different value than source->elem - enforce overwriting result->elem_len with source->elem_len It is not necessary to explicitly refer to "deferred-length" since this is enforced by [478:21] in the critical case, and there should be no problem for such descriptors created inside C. 3. Suggested edits against 18-007r1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In 18.5.5.9 The CFI_setpointer function - [491:27] delete "elem_len, ". - [491:28+] add new sentence "If source is not a null pointer and the C descriptor with the address result does not describe a 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] replace "base_addr and dim" by "base_addr, dim and possibly elem_len" - [491:38+] add new sentence "If the C descriptor with the address result describes a character pointer, the value of its elem_len member is set to source->elem_len".