http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48858
--- Comment #1 from Bill Long <longb at cray dot com> 2011-05-03 21:51:29 UTC
---
As an aside, the code in the Description is a "work-around" to avoid using the
TR 29113 feature that allows Optional arguments. This would be the preferred
code in the future:
> cat cknew1.f90
module graph_partitions
use,intrinsic :: iso_c_binding
interface
subroutine Cfun (num, array) bind(c, name="Cfun")
import :: c_int
integer(c_int),value :: num
integer(c_int),optional:: array(*)
end subroutine Cfun
end interface
end module graph_partitions
program test
use graph_partitions
integer(c_int) :: a(100)
call Cfun (1, a)
call Cfun (2)
end program test
The Intel and PGI compilers already support this (no compile errors, correct
output). The Cray compiler also does if the NEW_FORTRAN environment variable
is set (which just disables the error about having an OPTIONAL dummy in a
BIND(C) interface).
It is a separate issue from this BUG, but it might be a nice enhancement to
enable the TR feature of allowing OPTIONAL arguments in BIND(C) interfaces. It
appears that some other vendors have already jumped on that bandwagon.