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

Possible bug in ifort and ifx with interface shadowing variable

D_Dickinson
Beginner
464 Views

I recently encountered a failure in CI for a build using ifx which appears to be due to some conflicts between a module level variable with the same name as an interface declared in a different module. This seems to impact the most recent ifx (on compiler explorer) back to at least ifort 19. The same code compiles with gfortran, flang and nvfortran.

 

In psuedo code the problem looks a bit like

 

file: first.f90

 

module first

interface the_name
.....

end module first

 

file: second.f90

 

module second
logical :: the_name = .true.
...
contains

subroutine action
if(the_name) call sub_action
call second_action(arg = the_name)
end subroutine action

subroutine action
use first, only: the_name
call the_name
end subroutine action
.....
end module second

 

I find that ifx complains about line 8 of second.f90:

 

error #8164: A generic interface name shall not be used as an actual argument.   [THE_NAME]
       call second_action(arg = the_name)
-------------------------------------^
compilation aborted for /app/example.f90 (code 1)
Compiler returned: 1

 

 

I have constructed a minimal example on the compiler explorer (with a slightly different setup): https://godbolt.org/z/5cY88nvez 

0 Kudos
1 Reply
D_Dickinson
Beginner
321 Views

Is there anything else I can provide to help with diagnosing this? 

 

I appreciate that this might seem like it arises from bad practice (using the same name for two distinct objects), but I'm not aware of anything that should prevent this being valid fortran (might be lack of knowledge of my part though!). I can confirm that renaming on use (use first, only: the_name_ => the_name)  avoids the issue.

 

0 Kudos
Reply