[J3] Question about "Ambiguous interfaces in generic interface"

Jeff Hammond jehammond at nvidia.com
Fri Oct 7 13:36:52 UTC 2022


I am trying to understand why GCC Fortran (12.2) rejects this code, whereas Cray and Intel are happy with it (and NVHPC is too, if I use something other than type(*)).

As best I can tell, GCC has been buggy in this respect since 4.8 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66409), which seems like a staggering amount of time to not support something like this, so I wonder if there is some ambiguity in how strict the standard is here (https://stackoverflow.com/questions/66260342/problem-with-ambiguous-interfaces-with-gfortan suggests so).

I changed buf to all sorts of things to no avail, so it seems that gfortran cannot tolerate any other interface when one of them is of the form of the second.

Thanks,

Jeff

PS Yes, Bill, I know this is not the correct signature of MPI_Bcast.  This is an MCVE.


module mpi_coll_f
    use iso_c_binding, only: c_int, c_ptr
    implicit none

    interface MPI_Bcast
        module procedure MPI_Bcast_f08
        module procedure MPI_Bcast_f08ts
    end interface MPI_Bcast

    contains

        subroutine MPI_Bcast_f08(buf)
            type(c_ptr) :: buf
        end subroutine MPI_Bcast_f08

        subroutine MPI_Bcast_f08ts(buffer)
            type(*), dimension(..), intent(inout) :: buffer
        end subroutine MPI_Bcast_f08ts

end module mpi_coll_f



$ ifort -std18 -c confused.F90  && echo OK
OK



% gfortran-12 -std=f2018 -c confused.F90
confused.F90:12:32:

   12 |         subroutine MPI_Bcast_f08(buf)
      |                                1
......
   16 |         subroutine MPI_Bcast_f08ts(buffer)
      |                                  2
Error: Ambiguous interfaces in generic interface 'mpi_bcast' for 'mpi_bcast_f08' at (1) and 'mpi_bcast_f08ts' at (2)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20221007/15bf129e/attachment.htm>


More information about the J3 mailing list