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

            Bug ID: 120355
           Summary: Type mismatch for passed external function, if
                    external function appears in the same source file
           Product: gcc
           Version: 15.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jsberg at bnl dot gov
  Target Milestone: ---

Created attachment 61470
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61470&action=edit
Fortran source demonstrating the bug

Compile the attached source with

gfortran bug-250519a.f90 -o bug-250519a

Compiler output is 

bug-250519a.f90:12:9:

   12 |   call t(s,i,j)
      |         1
......
   29 | function s(x) result(y)
Error: Type mismatch at (1) passing global function ā€˜s’ declared at (2)
(UNKNOWN/INTEGER(4))

If I put the external function at the end in a separate source file, the code
compiles without error.

OS is Arch, but I built gcc from 15.1.0 source to verify that the bug appears
in the released version:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/home/jsberg/opt/gcc-15.1.0/libexec/gcc/x86_64-pc-linux-gnu/15.1.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-15.1.0/configure --prefix=/home/jsberg/opt/gcc-15.1.0
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.1.0 (GCC)

Reply via email to