[Bug fortran/48858] New: Incorrect error for same binding label on two generic interface specifics
longb at cray dot com
gcc-bugzilla@gcc.gnu.org
Tue May 3 21:59:00 GMT 2011
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.
More information about the Gcc-bugs
mailing list