public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/48858] New: Incorrect error for same binding label on two generic interface specifics
@ 2011-05-03 21:59 longb at cray dot com
  2011-05-03 21:51 ` [Bug fortran/48858] " longb at cray dot com
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: longb at cray dot com @ 2011-05-03 21:59 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Incorrect error for same binding label on two generic
                    interface specifics
           Product: gcc
           Version: 4.5.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: longb@cray.com


For this example code:

> cat ck1.c
#include <stdio.h>
void Cfun ( int n, int *array){

  if ( array == NULL )
    printf ( "call %d passes NULL as arg 2 \n", n);
  else
    printf ( "call %d passes array address as arg 2 \n", n);
}

[The C part compiles fine.]

> cat ck.f90
module graph_partitions
  use,intrinsic :: iso_c_binding

  interface Cfun
     subroutine cfunc1 (num, array) bind(c, name="Cfun")
       import :: c_int
       integer(c_int),value :: num
       integer(c_int)       :: array(*)
     end subroutine cfunc1

     subroutine cfunf2 (num, array) bind(c, name="Cfun")
       import :: c_int, c_ptr
       integer(c_int),value :: num
       type(c_ptr),value    :: array
     end subroutine cfunf2
  end interface
end module graph_partitions

program test
  use graph_partitions
  integer(c_int) :: a(100)

  call Cfun (1, a)
  call Cfun (2, C_NULL_PTR)
end program test


I get

> gcc -c ck1.c
> gfortran ck.f90 ck1.o
ck.f90:11.22:

     subroutine cfunf2 (num, array) bind(c, name="Cfun")
                      1
ck.f90:5.22:

     subroutine cfunc1 (num, array) bind(c, name="Cfun")
                      2
Error: Binding label 'Cfun' in interface body at (1) collides with the global
entity 'Cfun' at (2)
ck.f90:20.22:

....

Same behavior for 4.5.2 and 4.6.0.

The same code compiles and executes fine with the Cray, Intel, and PGI
compilers.  The expected output is:

> ./a.out
call 1 passes array address as arg 2 
call 2 passes NULL as arg 2 
>

This code should compile.  There is only one "entity" with the binding lablel
"Cfun".  In the words in the standard, only one "entity of the program" with
this binding label.  The names cfunc2 and cfunc1 are both local identifiers.
(Sections 16.2 and 16.3).

This construction is specifically allowed in the standard to allow users to
call a C function with multiple interfaces, similar to what is illustrated
here.


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2013-05-22  9:17 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-03 21:59 [Bug fortran/48858] New: Incorrect error for same binding label on two generic interface specifics longb at cray dot com
2011-05-03 21:51 ` [Bug fortran/48858] " longb at cray dot com
2011-05-04  8:24 ` burnus at gcc dot gnu.org
2011-05-04 22:43 ` longb at cray dot com
2011-05-06 18:18 ` burnus at gcc dot gnu.org
2011-05-06 18:39 ` burnus at gcc dot gnu.org
2011-05-22 14:41 ` burnus at gcc dot gnu.org
2011-07-24 19:19 ` dfranke at gcc dot gnu.org
2011-07-24 19:57 ` burnus at gcc dot gnu.org
2012-01-07 22:15 ` burnus at gcc dot gnu.org
2012-01-07 22:18 ` burnus at gcc dot gnu.org
2012-01-07 22:31 ` burnus at gcc dot gnu.org
2012-06-25 15:38 ` burnus at gcc dot gnu.org
2012-11-13 18:15 ` juno.krahn at nih dot gov
2013-05-20 20:09 ` burnus at gcc dot gnu.org
2013-05-20 20:10 ` burnus at gcc dot gnu.org
2013-05-20 20:14 ` burnus at gcc dot gnu.org
2013-05-22  9:17 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).