https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102641
Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |burnus at gcc dot gnu.org --- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> --- The issue with the code in comment 0 is that GCC has in resolve.c's resolve_symbol: if (sym->ts.type == BT_DERIVED .... if ((!a->save && !a->dummy && !a->pointer ... apply_default_init (sym); and likewise a few lines below for BT_CLASS. As there is now code which references the dummy variable, the error Assumed-rank variable y at (1) may only be used as actual argument is shown. * * * And in a similar vain, the following produces an ICE. It is quite similar but as it uses an allocatable component, the code is generated after resolving the symbols - such that an ICE and not a bogus error is the result: module m implicit none (type, external) type t integer, allocatable :: x end type t contains subroutine foo(x) type(t), intent(out) :: x(..) end end Note: C839 (→ PR 54753) prevents some odd corner cases (involving assumed size arrays). One way to handle it would be to handle it in the caller and not in the callee. However, this still requires support for assumed-rank as the following should be valid: subroutine foo(x) type(t), intent(out) :: x(..) ... subroutine bar(y) type(t), allocatable :: y(..) call foo(x) (y has to be either allocatable or a pointer in order not to violate C839.) As the issue with finalization, polymorphism, allocatable components and default initialization cannot occur with BIND(C), there is no issue if foo or bar is BIND(C).