From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 172073858410; Thu, 6 Jan 2022 15:39:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 172073858410 From: "trnka at scm dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/103931] New: Type name "c_ptr" is ambiguous when iso_c_binding is imported both directly and indirectly Date: Thu, 06 Jan 2022 15:39:07 +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: 10.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: trnka at scm 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 attachments.created 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: Thu, 06 Jan 2022 15:39:08 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D103931 Bug ID: 103931 Summary: Type name "c_ptr" is ambiguous when iso_c_binding is imported both directly and indirectly Product: gcc Version: 10.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: trnka at scm dot com Target Milestone: --- Created attachment 52135 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52135&action=3Dedit full testcase demonstrating the bug Compiling the attached test case fails for me on gfortran 11.2.1 20210728 (= Red Hat 11.2.1-1): $ gfortran -c gcc-ambiguous-cptr.f90 gcc-ambiguous-cptr.f90:97:19: 97 | type (C_PTR) :: context | 1 Error: Type name =E2=80=98c_ptr=E2=80=99 at (1) is ambiguous (Sorry for the convoluted module structure, I can't seem to reduce it furth= er without making the issue disappear.) The issue occurs in this piece of code: subroutine HProc() use FModule use ISO_C_BINDING use GModule type (C_PTR) :: context end subroutine Here, both FModule and GModule use ISO_C_BINDING indirectly in different wa= ys, so their module files contain c_ptr which gets picked up. Apparently, c_ptr then gets marked as ambiguous by check_for_ambiguous() in module.c:read_module() while reading GModule. After compiling it once as above to generate all the modules, you can add "= -cpp -DNODEPS=3D1" for further testing to focus on the problematic part (using existing module files). Strangely enough, gfortran 9.3.1 20200804 compiles the test without errors = when compiling everything but fails with the above error with NODEPS. gfortran 11 fails in both modes. Not sure if that counts as a regression or if it's jus= t a random coincidence. I can bisect that if desired.=