(j3.2006) Binding label and bind(c) procedure name scopes

Bill Long longb
Tue May 26 11:51:53 EDT 2015


On May 26, 2015, at 9:42 AM, Daniel C Chen <cdchen at ca.ibm.com> wrote:

> Bill said:
> <<<
> ....
> The argument for allowing this, based on 15-007,  is that the ?entity of the program? in the first interface is the external subroutine that has ?csub" as its binding label. Another entity of the program is  the external subroutine with the binding label ?sub?.  Since the same entity cannot have two different binding labels (your quote above), these two external subroutines are necessarily different.
> >>>
> 
> Will this argument make Case 3 illegal? 

No. Case 3 is fine - only a minor variation of what has long been allowed: putting an interface for an external procedure in a program unit.  The interface is the same in every program unit where you want to declare the procedure.  There is only one actual entity here, with a separate declaration in each subprogram.

> 
> Because if we treat external subroutine 's' in 'sub1' as a different entity from 's' in 'sub2', it seems it violates [473:27-28]
> "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?"

But S is not a global identifier in these examples. 

> 
> I also think we should allow Case 2. 
> 
> Is changing the following sentence in the standard what we need?
> 
> ""An entity of the program shall not be identified by more than one binding label.""
> To
> "An entity of the scope unit shall not be identified by more than one binding label.?

I don?t think this change is needed (or advisable) . The example does not violate the original text.  In Case 2 there are two entities of the program, each with just one global identifier, which is its binding label.   Having two binding labels for the same entity will cause problems for the linker, so this rule is not just a local scope issue.

Cheers,
Bill


> 
> 
> Thanks,
> 
> Daniel
> 
> XL Fortran Development - IBM Toronto Software Lab
> Phone: 905-413-3056   
> Tie: 969-3056   
> Email: cdchen at ca.ibm.com
> http://www.ibm.com/software/awdtools/fortran/xlfortran
> 
> <graycol.gif>Bill Long ---05/26/2015 08:53:14---On May 26, 2015, at 1:23 AM, Malcolm Cohen <malcolm at nag-j.co.jp> wrote: I agree that Cases 1 and 3 a
> 
> From:	Bill Long <longb at cray.com>
> To:	fortran standards email list for J3 <j3 at mailman.j3-fortran.org>
> Date:	05/26/2015 08:53
> Subject:	Re: (j3.2006) Binding label and bind(c) procedure name scopes
> Sent by:	j3-bounces at mailman.j3-fortran.org
> 
> 
> 
> 
> On May 26, 2015, at 1:23 AM, Malcolm Cohen <malcolm at nag-j.co.jp> wrote:
> 
> 
> I agree that Cases 1 and 3 are OK. 
> 
> > <<<
> > Case 2:
> > 
> > Module m
> > Contains
> >  Subroutine sub1()
> >    Interface
> >      Subroutine s() Bind(C, name="csub")
> >      End
> >    End interface
> >  End
> >  Subroutine sub2()
> >    Interface
> >      Subroutine s() Bind(C, name="sub")
> >      End
> >    End interface
> >  End
> > End module
> > 
> > 
> > Is this code legal? Again, it seems fine to me, but it seems disallowed by the 
> > standard at [474:26]
> > "An entity of the program shall not be identified by more than one binding 
> > label."
> >>>> 
> > 
> > Yes, this is invalid and rejected by some existing compilers.  This has been 
> > discussed in the past.
> 
> And other compilers will accept it.  I thought we already changed the standard to allow this.  There was certainly a desire by some that this be allowed.  The argument for allowing this, based on 15-007,  is that the ?entity of the program? in the first interface is the external subroutine that has ?csub" as its binding label. Another entity of the program is  the external subroutine with the binding label ?sub?.  Since the same entity cannot have two different binding labels (your quote above), these two external subroutines are necessarily different.  
> 
> Inside sub1() the statement  CALL S ( ) results in a call to csub.   Similarly, in sub2( ), CALL S( ) results in a call to sub.    In 16.2, the name of an  "external procedure with no binding label? is a global identifier.  In 16.3 the names of "external procedures that have binding labels? are local identifiers.  So, in both sub1 sub2, the names S are local identifiers.  Since they are in  different scopes, there is no conflict with the standard, and no ambiguity in the implementation. 
> 
> Cheers,
> Bill
> 
> > 
> > If we want to allow this we are going to have to reword 16.2p1 much much more 
> > carefully; for a start, so that external procedures with binding labels don't 
> > appear twice in the list, to avoid confusion.  I am sympathetic to such a 
> > request.
> 
> Bill Long                                                                       longb at cray.com
> Fortran Technical Support  &                                  voice:  651-605-9024
> Bioinformatics Software Development                     fax:  651-605-9142
> Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101
> 
> 
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3
> 
> 
> _______________________________________________
> J3 mailing list
> J3 at mailman.j3-fortran.org
> http://mailman.j3-fortran.org/mailman/listinfo/j3

Bill Long                                                                       longb at cray.com
Fortran Technical Support  &                                  voice:  651-605-9024
Bioinformatics Software Development                     fax:  651-605-9142
Cray Inc./ Cray Plaza, Suite 210/ 380 Jackson St./ St. Paul, MN 55101





More information about the J3 mailing list