Generic type-bound procedure



I have a couple of examples that work with generic procedures:

C:\gfortran\clf\opengl3>type generic1.f90
module mytypes
implicit none
interface gen
function f(x)
real f, x
end function f
function g(x)
integer g, x
end function g
end interface
pointer(f1,f)
pointer(g1,g)
end module mytypes

module funcs
implicit none
contains
function f(x)
real f, x
f = 3*x
end function f
function g(x)
integer g, x
g = 3*x
end function g
end module funcs

program test
use mytypes
use funcs, f2=>f, g2=>g
implicit none

f1 = LOC(f2)
g1 = LOC(g2)
write(*,*) gen(1)
write(*,*) gen(1.0)
end program test

C:\gfortran\clf\opengl3>gfortran -fcray-pointer generic1.f90 -ogeneric1

C:\gfortran\clf\opengl3>generic1
3
3.0000000

C:\gfortran\clf\opengl3>type generic3.f90
module mytypes
implicit none
abstract interface
function f(x)
real f, x
end function f
function g(x)
integer g, x
end function g
end interface
procedure(f),pointer,save :: f1
procedure(g),pointer,save :: g1
interface gen
procedure f1,g1
end interface gen
end module mytypes

module funcs
implicit none
contains
function f(x)
real f, x
f = 3*x
end function f
function g(x)
integer g, x
g = 3*x
end function g
end module funcs

program test
use mytypes
use funcs, f2=>f, g2=>g
implicit none

f1 => f2
g1 => g2
write(*,*) gen(1)
write(*,*) gen(1.0)
end program test

C:\gfortran\clf\opengl3>gfortran generic3.f90 -ogeneric3
generic3.f90: In function 'test':
generic3.f90:38:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

OK, almost works. I can't tell why this is so difficult when
the same compiler accepts the code of:

http://groups.google.com/group/comp.lang.fortran/msg/dca985833b0716c7?hl=en

without complaint. Anyhow, I was hoping to extend the latter
rather inauspicious example to user-defined types:

C:\gfortran\clf\opengl3>type generic4.f90
module mytypes
implicit none
abstract interface
function f(x)
real f, x
end function f
function g(x)
integer g, x
end function g
end interface
type T
procedure(f),pointer,NOPASS :: f1
procedure(g),pointer,NOPASS :: g1
contains
GENERIC :: gen => f1, g1
end type T
end module mytypes

module funcs
implicit none
contains
function f(x)
real f, x
f = 3*x
end function f
function g(x)
integer g, x
g = 3*x
end function g
end module funcs

program test
use mytypes
use funcs, f2=>f, g2=>g
implicit none
type(T) tau

tau%f1 => f2
tau%g1 => g2
write(*,*) tau%gen(1)
write(*,*) tau%gen(1.0)
end program test

C:\gfortran\clf\opengl3>gfortran generic4.f90 -ogeneric4
generic4.f90:15.26:

GENERIC :: gen => f1, g1
1
Error: Undefined specific binding 'g1' as target of GENERIC 'gen' at (1)
generic4.f90:33.14:

use mytypes
1
Fatal Error: Can't open module file 'mytypes.mod' for reading at (1): No
such fi
le or directory
gfortran: internal compiler error: Aborted (program f951)
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.

Pretty much syntactically the same as example3.f90, but with derived
types. If example4.f90 is nonconforming does that mean that
example3.f90 is taking advantage of an extension?

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end


.



Relevant Pages