As reported by Chris: For the following code, the bind(C) is ignored when calling the private specific subroutine "test" via calling the generic procedure "gen". Result: The procedure "test_" is called and the linker complains. If one makes "test" public, it works. As -fdump-parse-tree shows (after applying the fixes from PR34186), in "main" "test" has the "bind(c)" attribute. subroutine test() bind(c) end subroutine test module mod private public :: gen interface gen subroutine test() bind(c) end subroutine test end interface gen end module mod program main use mod call gen end program main
Some more debugging. The problem is that in gfc_conv_function_call / gfc_sym_mangled_function_id of "main", is_bind_c=1 but binding_label = '\0'. Actually, already for gfc_search_interface, I get sym=test and bind= '\0'. Educated guess: The problem is in module.c; the binding label is properly written into the .mod file (from looking at it) but in load_generic_interfaces, the "gfc_get_symbol (p, NULL, &sym);" returns for p = "test" no binding name.
Subject: Bug number PR34187 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-11/msg01165.html
Subject: Bug 34187 Author: burnus Date: Sat Nov 24 00:11:38 2007 New Revision: 130386 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130386 Log: 2007-11-23 Tobias Burnus <burnus@net-b.de> PR fortran/34187 * module.c (load_needed): Ensure binding_label is not lost. * decl.c (set_binding_label,gfc_match_bind_c): Replace strncpy by strcpy. 2007-11-23 Tobias Burnus <burnus@net-b.de> PR fortran/34187 * gfortran.dg/bind_c_usage_15.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/bind_c_usage_15.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/fortran/module.c trunk/gcc/testsuite/ChangeLog
FIXED on the trunk (4.3.0). Does not affect earlier versions of gfortran.