- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Compiler: ifx (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.
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for the bug report and workaround. I have confirmed and escalated this case to our compiler engineering for a fix.
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you very much for the bug report and workaround. I have confirmed and escalated this case to our compiler engineering for a fix.
![](/skins/images/D2683F18326913BBA0436CB7114DD569/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page