Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28441 Discussions

COMPILER BUG(?): incorrect "Ambiguous generic interface" error

DataScientist
Valued Contributor I
1,108 Views

The following code appears to be standard-conforming,

module container_module

    use iso_fortran_env

    integer, parameter :: lkc = logical_kinds(1)
    integer, parameter :: ikc = integer_kinds(1)

    type :: container_ik(kind)
        integer         , kind  :: kind = integer_kinds(1)
        integer(kind)           :: value
    end type

    type :: container_lk(kind)
        integer         , kind  :: kind = logical_kinds(1)
        logical(kind)           :: value
    end type

end module

module disp_module

    use container_module

    type :: disp_type
    end type

    interface show
    module subroutine show_logical(disp, object)
        use container_module, only: container => container_lk
        class(disp_type)        , intent(inout)               :: disp
       !type(container_lk(lkc)) , intent(in)                  :: object
        type(container(lkc))    , intent(in)                  :: object
    end subroutine
    module subroutine show_integer(disp, object)
        use container_module, only: container => container_ik
        class(disp_type)        , intent(inout)               :: disp
       !type(container_ik(ikc)) , intent(in)                  :: object
        type(container(ikc))    , intent(in)                  :: object
    end subroutine
    end interface

end module

end

but Intel ifort 2021.5 generates the following error,

error #5286: Ambiguous generic interface SHOW: previously declared specific procedure SHOW_LOGICAL is not distinguishable from this declaration. [SHOW_INTEGER]
    module subroutine show_integer(disp, object)
----------------------^

The error however is incorrect because the two interfaces are different.

The issue appears to be with the renaming of the module entities within the interfaces to the same aliases ("container"). If we uncomment the commented lines to use the type names explicitly, then the error is resolved.

This appears to be a bug in ifort unless someone can explain the bizarre behavior observed above. For reference, gfortran is fine with both implementations. The code can be tested here with different ifort and other compilers.

 

 

 

 

0 Kudos
1 Solution
Ron_Green
Moderator
982 Views

We're creating a bug report.  Thank you for bringing this to our attention.

View solution in original post

4 Replies
FortranFan
Honored Contributor II
1,040 Views

For whatever it's worth, I agree the code in the original post appears to conform to the Fortran standard.

Ron_Green
Moderator
983 Views

We're creating a bug report.  Thank you for bringing this to our attention.

Devorah_H_Intel
Moderator
347 Views

The fix is scheduled for 2024.2 release of IFX, planned for July. 

DataScientist
Valued Contributor I
273 Views

Thank you for the fix!

Reply