[Bug fortran/85448] the compiler selects the wrong subroutine because of bind(c,name=...)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85448 kargl at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED CC||kargl at gcc dot gnu.org Resolution|--- |INVALID --- Comment #1 from kargl at gcc dot gnu.org --- (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. $ gfcx -c m1.f90 $ nm m1.o T __m1_MOD_odopen U _gfortran_st_write U _gfortran_st_write_done U _gfortran_transfer_character_write $ gfcx -c m2.f90 $ nm m2.o U _gfortran_st_write U _gfortran_st_write_done U _gfortran_transfer_character_write T odopen
[Bug fortran/85448] the compiler selects the wrong subroutine because of bind(c,name=...)
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
[Bug fortran/85448] the compiler selects the wrong subroutine because of bind(c,name=...)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85448 --- Comment #3 from francois.jacq at irsn dot fr --- Notice that this is a regression : The version 4.8.5 returns the result I expected...
[Bug fortran/85448] the compiler selects the wrong subroutine because of bind(c,name=...)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85448 --- Comment #4 from Steve Kargl --- On Thu, Apr 19, 2018 at 09:07:15AM +, francois.jacq at irsn dot fr wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85448 > > --- Comment #3 from francois.jacq at irsn dot fr --- > Notice that this is a regression : The version 4.8.5 returns the result I > expected... > Or it was a bug in 4.8.5 and is now fixed. Now, the version where you rename odopen from m1 to odopen_m1 is probably a bug.
[Bug fortran/85448] the compiler selects the wrong subroutine because of bind(c,name=...)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85448 --- Comment #5 from francois.jacq at irsn dot fr --- On Thursday 19 April 2018 16:30:09 you wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85448 > > --- Comment #4 from Steve Kargl > --- > > On Thu, Apr 19, 2018 at 09:07:15AM +, francois.jacq at irsn dot fr wrote: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85448 > > > > --- Comment #3 from francois.jacq at irsn dot fr --- > > Notice that this is a regression : The version 4.8.5 returns the result I > > expected... > > Or it was a bug in 4.8.5 and is now fixed. > > Now, the version where you rename odopen from m1 > to odopen_m1 is probably a bug. No : both are bugs (and probably identical). The bind clause cannot change how the procedure name "odopen" has to be considered from the Fortran side ! Intel, Oracle and Nag compilers agree with me.
[Bug fortran/85448] the compiler selects the wrong subroutine because of bind(c,name=...)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85448 kargl at gcc dot gnu.org changed: What|Removed |Added Priority|P3 |P4 Status|RESOLVED|REOPENED Last reconfirmed||2018-04-19 CC|kargl at gcc dot gnu.org | Resolution|INVALID |--- Ever confirmed|0 |1 --- Comment #6 from kargl at gcc dot gnu.org --- Re-open. Remove my email address. Let someone else deal with the problem.
[Bug fortran/85448] the compiler selects the wrong subroutine because of bind(c,name=...)
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85448 Thomas Koenig changed: What|Removed |Added Keywords||diagnostic Status|REOPENED|NEW CC||tkoenig at gcc dot gnu.org Severity|normal |enhancement --- Comment #7 from Thomas Koenig --- As quoted by Steve Lionel on c.l.f (F2008, 16.2, para 2): "The global identifier of an entity shall not be the same as the global identifier of any other entity. Furthermore, a binding label shall not be the same as the global identifier of any other global entity, ignoring differences in case." So, the code is invalid. Since this is not a constraint, the compiler can do anything it pleases. It would be nice to have an error message, though; should be straightforward to implement.