Hi,
I have put it in the “Help” category but maybe I misclassified and it should be in compilers.
I have stumbled on the following curiosity. Consider the code below:
module A
implicit none
contains
subroutine foo()
print *, "A"
end subroutine
end module A
module B
implicit none
contains
subroutine foo()
print *, "B"
end subroutine
end module B
program main
use A, only: foo
use B, only: foo
implicit none
end program main
On godbolt: Compiler Explorer
This code is accepted by gfortran,flang and LFortran, which is kind of consistent with my reading on the section 14.2.2 paragraph 8 of Fortran 2023 standard (https://j3-fortran.org/doc/year/24/24-007.pdf), which reads:
An ultimate entity is a module entity that is not accessed by use association. An accessed entity shall not be associated with two or more ultimate entities unless its identifier is not used, or the ultimate entities are generic interfaces. Generic interfaces are handled as described in 15.4.3.4.
However the above snippet is rejected by Intel compilers e.g. Compiler Explorer
Out of pure curiosity I just wonder what is the “correct” behavior in this case. Should explicitly specifying use association (? not sue I am using the term right) in use A, only: foo be considered “using an identifier”.
I was just hoping that people more knowledgeable about Fortran could have some extra insight ![]()