https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94070
--- Comment #9 from Tobias Burnus <burnus at gcc dot gnu.org> --- I think my patch for moving the CFI<->GFC conversion to FE-generated code partially helps, https://gcc.gnu.org/pipermail/gcc-patches/2021-September/578904.html However, I still see the following issues: integer :: y(-1:3,4,*) call test(y, num=0) -> subroutine test (x, num) integer :: x(..), num print *, shape(x) print *, size (x); if (size (x) /= -20) print *, 'ERROR: 1' 5 4 -1 0 That's unrelated to BIND(C) as there is no BIND(C). The problem is in gcc/fortran/trans-intrinsic.c, where gfc_conv_intrinsic_shape has code for AS_ASSUMED_RANK but gfc_conv_intrinsic_size does not. → Same result with BIND(C). Likewise for: print *, size (x, dim=3); if (size (x, dim=3) /= -1) print *, 'ERROR: 4' which also shows 0 instead of -1. – Same, except that the by-dimension results are not summed up. * * * 5 4 -1 ERROR 65 Expected is: 5, 4, 1 – the problem is that the last dimension is -1:-1. Looks as if gfc_conv_intrinsic_shape misses a check whether the argument is !attr.allocatable && !attr.pointer with symbol_attribute attr = gfc_expr_attr (expr); before assuming that the argument can be assumed size. → Same issue with BIND(C). * * * The following does not occur with BIND(C) - with my patch applied - but without BIND(C): ERROR: 25 5 4 -1 Another SHAPE issue. Issue: Last value should be '1' not '-1' as the argument is: allocate (B(-1:3,4,-1:-1)) The dump shows: test (&b, &C.4394); thus, the actual argument has the declared bounds – while in the callee is should have '1' as lower bound. I am not sure whether that's a caller or a callee problem. If handled in the caller, the following needs to work: subroutine bar(x) integer, allocatable :: x(..) print*, lbound(x) ! -> has allocated bounds call test(x) i.e. assumed-rank allocatable -> assumed-rank nonallocatable. In general, we have code which generates a temporary descriptor, e.g. for 'call test(b(:,:,:))'. (With C binding, we generate code which sets lbound to 0 in the caller.) → gfc_conv_procedure_call for the call handling / gfc_conv_expr_descriptor for the conversion. I wonder whether we need to set se->direct_byref = 0 in this case. Additionally failing: 5 4 -1 ERROR: 31 -1 ERROR 34 Same cause – just exposed via UBOUND() and UBOUND(…,dim=3). And also only without BIND(C).