Bug 38386 - Update BIND(C,name=) checking for Fortran 2008
Update BIND(C,name=) checking for Fortran 2008
Status: RESOLVED DUPLICATE of bug 35161
Product: gcc
Classification: Unclassified
Component: fortran
4.4.0
: P3 enhancement
: ---
Assigned To: Not yet assigned to anyone
:
Depends on:
Blocks: 32630 39627
  Show dependency treegraph
 
Reported: 2008-12-03 16:38 UTC by Tobias Burnus
Modified: 2010-05-09 14:08 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-03-29 08:03:11


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2008-12-03 16:38:54 UTC
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.
Comment 1 Daniel Franke 2009-01-04 00:48:59 UTC
See also PR35161.
Comment 2 Daniel Franke 2010-05-09 14:08:00 UTC

*** This bug has been marked as a duplicate of 35161 ***