(j3.2006) Binding label and bind(c) procedure name scopes
Bill Long
longb
Tue May 26 08:52:58 EDT 2015
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
More information about the J3
mailing list