https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101309
Bug ID: 101309 Summary: Bind(C): gfortran creates invalid C descriptor for result of TRANSPOSE intrinsic Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: sandra at gcc dot gnu.org Target Milestone: --- The description of CFI_cdesc_t in section 18.5.3 of the 2018 Fortran standard includes this constraint: There shall be an ordering of the dimensions such that the absolute value of the sm member of the first dimension is not less than the elem_len member of the C descriptor and the absolute value of the sm member of each subsequent dimension is not less than the absolute value of the sm member of the previous dimension multiplied by the extent of the previous dimension. In the WIP TS 29113 testsuite posted here https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574115.html the testcase interoperability/fc-descriptor-7.f90 passes the result of the TRANSPOSE intrinsic to a C function with an assumed-shape array argument, and the descriptor it receives does not satisfy this constraint. It dumps as <CFI_cdesc_t base_addr=0x7ffcb2e98a40 elem_len=4 version=1 rank=2 type=CFI_type_int attribute=CFI_attribute_other dim=[<CFI_dim_t lower_bound=0 extent=5 sm=40>, <CFI_dim_t lower_bound=0 extent=10 sm=4>]>