This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug fortran/38386] New: Update BIND(C,name= checking for Fortran 2008


At the J3 / WG5 mailing list (reply by Bill Long):

Reinhold Bader wrote:
> >
> > before taking this offline, I'd like to understand something about BIND(C)
> > which other people might know ...
> >
> > Take the following example program:
> >
> > module mod_label_interf
> >   use, intrinsic :: iso_c_binding
> >   implicit none
> >   interface foo
> >     subroutine foo_1(x, n, i) bind(c, name='Foo')
> >       import :: c_float, c_int
> >       real(c_float) :: x
> >       integer(c_int), value :: n, i
> >     end subroutine
> >     subroutine foo_2(x, n, i) bind(c, name='Foo')
> >       import :: c_float, c_int
> >       real(c_float) :: x(*)
> >       integer(c_int), value :: n, i
> >     end subroutine
> >   end interface
> > end module
> > program label_interf
> >   use mod_label_interf
> >   implicit none
> >   integer(c_int) :: i
> >   real(c_float) :: xx, xxx(3)
> >   i = 2
> >   call foo(xx, 1, i)
> >   call foo(xxx, 3, i)
> >   write(*, *) xx
> >   write(*, *) xxx
> > end program
> >
> > together with the C implementation
> >
> > #include <math.h>
> >
> > void Foo(float *x, int n, int i) {
> >   int j;
> >   for (j=0; j<n; j++) {
> >     *(x+j)  = (float) (i + j) + 0.1;
> >   }
> > }
> >
> > This code is accepted by various processors and executes in accordance with my
> > personal expectations (for what that is worth :-)).
> > It is not accepted by NAG's compiler, and also not by IBM xlf. NAG's error message is
> >
> > Error: label_interf.f90: Duplicate binding label 'Foo' for external procedure FOO_2 and external procedure FOO_1
> >   


This error message is consistent with the Fortran 2003 rules.  An 
(non-abstract) interface declares the procedure name to be external.  
However, in the case of a separate binding label, that rule is being 
changed in Fortran 2008 to be the way you want it. If there is a 
separate binding label then the procedure's name becomes a local name, 
not external.


-- 
           Summary: Update BIND(C,name=  checking for Fortran 2008
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38386


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]