https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69524
--- Comment #8 from Paul Thomas <pault at gcc dot gnu.org> --- (In reply to Paul Thomas from comment #7) > I could be wrong but I do not agree that this is valid code. I will turn to > it tomorrow. I believe that a MODULE SUBROUTINE/FUNCTION declaration cannot > appear in the contained part of a module. It seems that I was wrong. From the Fortran 2008 standard: C1247 (R1225) MODULE shall appear only in the function-stmt or subroutine-stmt of a module subprogram or of a nonabstract interface body that is declared in the scoping unit of a module or submodule. Modifying the gcc_assert (trans-decl.c:2065) that causes the ICE to bool module_procedure; module_procedure = sym->attr.module_procedure && sym->ns && sym->ns->proc_name && sym->ns->proc_name->attr.flavor == FL_MODULE; gcc_assert (!sym->attr.external || module_procedure); Gives what seems to be the correct behaviour and allows: module A interface module subroutine A1(i) integer i end subroutine A1 module subroutine B1(i) integer i end subroutine B1 end interface contains module subroutine A1(i) integer i print *, 'A::A1(): i == ', i end subroutine A1 end module A submodule (A) a_son contains module procedure b1 print *, 'A_SON::B1(): Calling A1' call a1(i) end procedure end submodule use A call b1 (42) end to do the right thing. I cannot remember at all where module procedures pick up the external attribute. It would be better to modify this at source rather than the fix above :-) Paul