11-127 To: J3 From: Nick Maclaren Subject: Interop TR: CFI_desc_t update issues Date: 2011 January 27 Reference: N1838, 10-235 1. Summary ---------- This issue was raised in 10-235, but the same remarks as in 11-126 apply. N1838 is couched entirely in terms of updates to descriptors. There are a few constraints, such as: 5.2.6.1 para. 2 constrains allocation and deallocation of allocatable objects to be permitted via CFI_allocate and CFI_deallocate only. This is repeated in 5.2.7 para. 1. 5.2.7 para. 1 states that the elem_len, version, rank, type and attribute members may not be updated after 'initialisation'. This does NOT constrain either the base or the dim member from being changed, for either pointer or assumed-shape, and they are obviously needed for pointers. However, it leads to questions like the following, where the answer 'yes' is likely to cause reasonable implementations severe problems: 1) Can a C function change the actual CFI_desc_t structure that was passed for an assumed-shape argument? 2) Can a Fortran processor change the actual CFI_desc_t structure that was passed for an assumed-shape argument? There are also updates that are syntactically impossible in Fortran, but are not forbidden by N1838 - which, in any case, uses semantic constraints and not syntactic ones. The same problems arise. For example: 3) A C function changes the base or dim members of the actual CFI_desc_t structure that was passed for a pointer argument with INTENT(IN). 4) A C function changes the dim members of the actual CFI_desc_t structure that was passed for an allocatable argument to refer to the same data (or a subset of it) in a different way. 5) A C function changes the base or dim members of the actual CFI_desc_t structure that was passed for a pointer argument in a way that would not be possible within Fortran. An example of the last would be a diagonalisation mapping; e.g. where the descriptor is passed as: elem_len = 1 rank = 2 dim[0].extent = 10 dim[0].sm = 2 dim[1].extent = 10 dim[2].sm = 50 and changed to: dim[0].extent = 10 dim[0].sm = 52 dim[1].extent = 1 dim[2].sm = 520 2. Problem ---------- As far as I can see, none of the above is forbidden by N1838 - but, also, pretty obviously, all of it is likely to cause trouble to at least some implementations. HOWEVER, I do NOT guarantee that I have thought of all of the problematic cases; others are likely to arise when people start to implement and use these facilities. I attempted to think of wording to exclude these cases within the design of 10-251, and failed.