https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92123
Bug ID: 92123 Summary: [F2018/array-descriptor] Scalar allocatable/pointer with array descriptor (via bind(C)): ICE with select rank or error scalar variable with POINTER or ALLOCATABLE in procedure with BIND(C) is not yet supported Product: gcc Version: 10.0 Status: UNCONFIRMED Keywords: ice-on-valid-code, rejects-valid Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: pault at gcc dot gnu.org Target Milestone: --- Found on https://mailman.j3-fortran.org/pipermail/j3/2019-October/011669.html The following shall use the array descriptor – and should work (TM): subroutine Fsub( dat ) bind(C, name="Fsub") integer(c_int), allocatable, intent(out) :: dat Currently, it fails with: Error: Scalar variable ‘dat’ at (1) with POINTER or ALLOCATABLE in procedure ‘fsub’ with BIND(C) is not yet supported Test program, see link to the J3 mailing list. * * * If one uses assumed-rank variables and adds 'select rank', it give an ICE. That is with subroutine fsub( dat ) bind(C, name="fsub") integer(c_int), allocatable, intent(out) :: dat(..) select rank (dat) rank (0) !dat = 42 !<-- A allocate( dat ) ; dat = 42 !<--- B end select It ICEs in gfc_conv_descriptor_data_get, at fortran/trans-array.c:145 Breakpoint 3, trans_associate_var (sym=0x24d8ed0, block=0x7fffffffd5f0) at ../../repos/gcc/gcc/fortran/trans-stmt.c:1845 1845 tmp = gfc_conv_descriptor_data_get (desc); (gdb) p debug_tree(desc) <var_decl 0x7ffff7fc7ab0 __tmp_INTEGER_4_rank_0 type <pointer_type 0x7ffff77429d8 type <integer_type 0x7ffff773b5e8 integer(kind=4) public SI which is a scalar without array descriptor.