https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85448

--- Comment #2 from francois.jacq at irsn dot fr ---
(In reply to kargl from comment #1)
> (In reply to francois.jacq from comment #0)
> > In the following example, the subroutine c_open of the module m2, which
> > should call the subroutine odopen of the module m1, calls itself instead...
> 
> The behavior you see is correct.  There is no 'c_odopen'
> in the m2.o file.  You gave it the binding name 'odopen'.
> You have created a recursive call.

No the behavior is not correct : at least, the compiler should issue an error
message precising that there is a name conflict because odopen is also
accessible via the instruction use.

Another variant which clearly shows that the compiler behavior is wrong :

module m2
   use iso_c_binding
   use m1, only : odopen_m1 => odopen
   implicit none
   contains
   subroutine c_odopen(unit) bind(c,name="odopen")
      integer(c_int),intent(out) :: unit
      write(*,*) 'c_odopen'
      call odopen_m1(unit)
   end subroutine
end module

With this variant, I get again the same behavior : c_odopen is called
recursively

Reply via email to