Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29281 Discussions

Compiler throws error on generic interface (ambiguous generic interface) / fix by reordering items

jeffhole
Novice
1,715 Views

Compilerifx (IFX) 2024.2.0 20240602 (ifx --version)

OS Rocky Linux 8.9 (Green Obsidian)

 

I have a generic interface that the compiler does not like. Here is the source that produces the error.

 

! file: produce_error.f90
module CalculateModule
    use, intrinsic :: iso_c_binding
    implicit none
    private
    public :: calculate

    interface calculate
        module procedure :: calculate_standard
        module procedure :: calculate_prealloc_standard
        module procedure :: calculate_prealloc_pointer
        module procedure :: calculate_pointer
    end interface

    interface
        module subroutine calculate_standard(x1,x2,x3,opt_1,opt_2)
            real(4), intent(in)                 :: x1(:), x2(:)
            real(4), intent(inout), allocatable :: x3(:)
            integer,     intent(in), optional   :: opt_1
            type(c_ptr), intent(in), optional   :: opt_2(3)
        end subroutine

        module subroutine calculate_pointer(x1,x2,x3,opt_1,opt_2)
            real(4), intent(in)               :: x1(:), x2(:)
            real(4), intent(inout), pointer   :: x3(:)
            integer,     intent(in), optional :: opt_1
            type(c_ptr), intent(in), optional :: opt_2(3)
        end subroutine

        module subroutine calculate_prealloc_standard(x1,x2,x3,x1full,x2full,x3full,fx1,fx2,fx3,opt_1,opt_2)
            real(4), intent(in)                    :: x1(:), x2(:)
            real(4), intent(inout), allocatable    :: x3(:)
            complex(4), allocatable, intent(inout) :: x1full(:), x2full(:)
            complex(4), allocatable, intent(inout) :: fx1(:), fx2(:), fx3(:)
            complex(4), allocatable, intent(inout) :: x3full(:)
            integer,     intent(in), optional      :: opt_1
            type(c_ptr), intent(in), optional      :: opt_2(3)
        end subroutine

        module subroutine calculate_prealloc_pointer(x1,x2,x3,x1full,x2full,x3full,fx1,fx2,fx3,opt_1,opt_2)
            real(4), intent(in)                    :: x1(:), x2(:)
            real(4), intent(inout), pointer        :: x3(:)
            complex(4), allocatable, intent(inout) :: x1full(:), x2full(:)
            complex(4), allocatable, intent(inout) :: fx1(:), fx2(:), fx3(:)
            complex(4), allocatable, intent(inout) :: x3full(:)
            integer,     intent(in), optional      :: opt_1
            type(c_ptr), intent(in), optional      :: opt_2(3)
        end subroutine
    end interface
end module

 

Run the compiler and here is the output

 

ifx -c produce_error.f90
produce_error.f90(23): error #5286: Ambiguous generic interface CALCULATE: previously declared specific procedure CALCULATE_STANDARD is not distinguishable from this declaration. [CALCULATE_POINTER]
        module subroutine calculate_pointer(x1,x2,x3,opt_1,opt_2)
--------------------------^
compilation aborted for produce_error.f90 (code 1)

 

Workaround

The strange thing is that reorganizing the items in the generic interface makes the compiler happy:

 

! BAD
interface calculate
    module procedure :: calculate_standard
    module procedure :: calculate_prealloc_standard
    module procedure :: calculate_prealloc_pointer
    module procedure :: calculate_pointer
end interface

! GOOD
interface calculate
    module procedure :: calculate_standard
    module procedure :: calculate_pointer
    module procedure :: calculate_prealloc_standard
    module procedure :: calculate_prealloc_pointer
end interface

 

I've attached the full workaround source.

Labels (1)
0 Kudos
1 Solution
Devorah_H_Intel
Moderator
1,561 Views

Thank you very much for the bug report and workaround. I have confirmed and escalated this case to our compiler engineering for a fix.


View solution in original post

0 Kudos
2 Replies
Devorah_H_Intel
Moderator
1,562 Views

Thank you very much for the bug report and workaround. I have confirmed and escalated this case to our compiler engineering for a fix.


0 Kudos
jeffhole
Novice
966 Views

I just wanted to check in on the status of this issue. Using 2025.2.0, this issue is still present.

The ticket opened on my behalf under Intel support says "closed: final" and that happened back in the middle of Dec 2024. The ticket number is 06274816, created 2024/07/01 12:29, and last updated 2024/12/19 00:48. I wonder if this was an accidental batch closing of tickets because another ticket (# 06274814) was last updated at the exact same date and time. The interesting thing is that the issue addressed in ticket #06274814 works now, so I'm just not sure (https://community.intel.com/t5/Intel-Fortran-Compiler/Bug-Report-ICE-5623-passing-re-im-parts-of-complex-arrays-to/m-p/1610785)

Thanks!

0 Kudos
Reply