From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4377A385843F; Tue, 22 Feb 2022 05:46:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4377A385843F From: "neil.n.carlson at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/104630] New: module subroutine not accessible from submodule Date: Tue, 22 Feb 2022 05:46:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: neil.n.carlson at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Feb 2022 05:46:23 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104630 Bug ID: 104630 Summary: module subroutine not accessible from submodule Product: gcc Version: 11.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: neil.n.carlson at gmail dot com Target Milestone: --- Consider this minimal example. File module.f90: module modA private type, public :: typeA contains procedure :: foo end type interface module subroutine foo(this) class(typeA) :: this end subroutine end interface contains subroutine bar(this) type(typeA) :: this end subroutine end module File submodule.f90: submodule(modA) foo_impl contains module subroutine foo(this) class(typeA) :: this call bar(this) ! a module subroutine in the host module end subroutine end submodule File main.f90: use modA end The implementation of subroutine foo in the submodule should have access to subroutine bar defined in its host module but it apparently does not judging from the link error: $ gfortran module.f90 submodule.f90 main.f90 /usr/bin/ld: /tmp/ccEycu6t.o: in function `__moda_MOD_foo': gfortran-20220221-submodule.f90:(.text+0x17): undefined reference to `__moda_MOD_bar' collect2: error: ld returned 1 exit status If the 3 program units are combined into a single file, that will compile and link without error.=