[Bug fortran/126872] New: Change in visibility of C bound functions with 16.2.0

rpmcnally at gmail dot com via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126872

            Bug ID: 126872
           Summary: Change in visibility of C bound functions with 16.2.0
           Product: gcc
           Version: 16.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rpmcnally at gmail dot com
  Target Milestone: ---

It appears to me that the 'private' keyword is now affecting C bound functions
in Fortran modules, though I believe that bind(C) is supposed to automatically
provide for external linkage.  I'm not sure if this is a bug or an intended
change.

    module moduleA

        implicit none

        private

    contains

    subroutine doThing() bind(C, name="doThing")
    end subroutine doThing

    end module moduleA

$ gfortran --version
GNU Fortran (GCC) 16.2.0

$ gfortran -fPIC -shared -o libmoduleA.so moduleA.f90

$ nm libmoduleA.so | grep -i dothing
0000000000000559 t doThing

Under gfortran versions 9.3, 12.2, 15.3, and 16.1 all produce a library with
external visibility instead of static.  It does appear the visibility can be
toggled by explicitly listing the C bound function as 'public'.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.