(j3.2006) binding labels and global identifiers

Bill Long longb
Tue Jun 14 08:29:03 EDT 2011



On 6/14/11 5:28 AM, Robert Corbett wrote:
> One of Oracle's other engineers working on Fortran raised
> a question regarding conflicting binding labels and global
> identifiers (see Clause 16.2 of 10-007r1).  He pointed out
> that many Fortran implementations, including Oracle's,
> construct the linker name for an external procedure or
> common block by adding a low line to the end of the global
> name of the procedure or common block.  Consider the
> following program:
>
>        MODULE variables
>          USE ISO_C_BINDING
>          PRIVATE
>          PUBLIC x
>          REAL, BIND(C, NAME="subr_") :: x = 0.1
>        END
>
>        SUBROUTINE subr
>          USE variables
>          PRINT *, x
>        END
>
>        PROGRAM main
>          CALL subr
>        END
>
> This program caused a problem for every implementation I
> tried.  I was amused that it failed in a different way for
> each implementation.  Nonetheless, the program does not
> appear to violate the requirements set out in Clause 16.2.
> The global identifier "subr" and the binding label "subr_"
> are different according to the language of Clause 16.2.
>
> Is the program presented above intended to be standard-
> conforming?  Implementations could easily be made to handle
> the program by using a different mapping of global names to
> linker names.  Making such a change might break backward
> compatibility.
>

I also got 5/5 failures with the compilers I tried.  Choosing a 
different name mangling scheme would help only if the Fortran-generated 
linker names contained characters that made them illegal as names in C, 
but still legal to the linker.   While solving this problem, it would 
upset assumptions made in legacy codes from the pre-interop era that 
were written based on the old trailing underscore convention.  Granted 
that there is a better and more portable way of accomplishing C 
interoperability now.  But such a  solution will probably require a 
compiler switch to recover the old name mangling scheme.

Cheers,
Bill


> Robert Corbett
> _______________________________________________
> J3 mailing list
> J3 at j3-fortran.org
> http://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