[J3] Question about "Ambiguous interfaces in generic interface"
Brad Richardson
everythingfunctional at protonmail.com
Fri Oct 7 14:03:36 UTC 2022
Well `type(*)` says *any* type, and `dimension(..)` says *any* rank, and `intent(inout)`, just requires it be defineable (i.e. a variable), so since that interface matches any argument, there would be no other interface that could be unambiguously distinct from it, so you can't put any other procedure in a generic interface with it (with the same number of arguments).
Unless somebody else thinks of something I'm missing, I think it's non-conforming.
Regards,
Brad
On Fri, 2022-10-07 at 13:36 +0000, Jeff Hammond via J3 wrote:
> 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/24aa8f49/attachment-0001.htm>
More information about the J3
mailing list