See the code below. It has 2 dangling routines foo()
and foo_1()
. In the program, an explicit interface is defined for foo_1()
, and then foo_1()
is listed under generic interface foo
. That is, the generic interface foo
has the same name as the dangling routine foo()
.
In all compilers I have tested (gfortran, ifx, nvfortran, flang, lfortran) the behavior is:
- no name conflict at compilation
- the generic interface “shadows” the dangling routine; that is, the program always prints
"foo_1"
Compiler Explorer
I guess then this is guaranteed by the standard (all the more than even with all warnings enabled, the compilers do not complain)… But it’s only a guess. Any comment?
subroutine foo()
print*, "foo"
end subroutine
subroutine foo_1()
print*, "foo_1"
end subroutine
program bar
interface
subroutine foo_1()
end subroutine
end interface
interface foo
procedure foo_1
end interface
call foo()
end