public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "trnka at scm dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-103931-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103931

            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=52135&action=edit
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 ‘c_ptr’ at (1) is ambiguous

(Sorry for the convoluted module structure, I can't seem to reduce it further
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 ways,
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=1" 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 just a
random coincidence. I can bisect that if desired.

             reply	other threads:[~2022-01-06 15:39 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-06 15:39 trnka at scm dot com [this message]
2022-01-06 16:55 ` [Bug fortran/103931] " marxin at gcc dot gnu.org
2022-01-06 21:40 ` anlauf at gcc dot gnu.org
2022-01-06 22:38 ` pinskia at gcc dot gnu.org
2022-01-06 22:42 ` pinskia at gcc dot gnu.org
2022-01-06 22:50 ` trnka at scm dot com
2022-01-06 22:54 ` pinskia at gcc dot gnu.org
2022-01-06 22:55 ` pinskia at gcc dot gnu.org
2022-01-07  7:03 ` marxin at gcc dot gnu.org
2023-03-31 20:12 ` anlauf at gcc dot gnu.org
2023-04-01 19:50 ` aldot at gcc dot gnu.org
2023-04-02 15:54 ` aldot at gcc dot gnu.org
2023-04-02 18:59 ` anlauf at gcc dot gnu.org
2023-04-12 17:20 ` aldot at gcc dot gnu.org
2023-04-12 18:56 ` anlauf at gcc dot gnu.org
2023-04-13 19:59 ` aldot at gcc dot gnu.org
2023-04-14 17:21 ` aldot at gcc dot gnu.org
2023-04-24 16:17 ` aldot at gcc dot gnu.org
2023-04-24 16:29 ` aldot at gcc dot gnu.org
2023-04-24 20:14 ` anlauf at gcc dot gnu.org
2023-04-25 18:16 ` anlauf at gcc dot gnu.org
2023-04-25 18:46 ` aldot at gcc dot gnu.org
2023-04-25 19:03 ` anlauf at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-103931-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).