Hello,
I'm really afraid of reporting this one...
Please tell me it is standard, and if it's not, that the standard is going to change:
module dummy_module implicit none type :: a_type integer(4) :: val end type a_type type :: b_type integer(4) :: val1 integer(4) :: val2 end type b_type contains function f(x) ! Variables class(*), target :: x class(*), pointer :: f ! Body of f f => x end function f end module dummy_module program polymorphism_test use dummy_module implicit none type(a_type), pointer :: a type(b_type), pointer :: b
allocate(b) b%val1 = 3.0 b%val2 = 4.0 a => f(b) end program polymorphism_test
Compiles with XE 2013 SP1 14.0.0100.12 and XE 2015 15.0.0107.2010 (and I think with Update 1 as well), which is perfect, but gfortran complains:
main.f90:38.8:
a => f(b)
1
Error: Data-pointer-object &L must be unlimited polymorphic, a sequence derived type or of a type with the BIND attribute assignment at (1) to be compatible with an unlimited polymorphic target
Edit:
I've just found this, it looks like it has not been resolved yet. I second antony on that, what a pity, 1000s of lines to rewrite, entire code broken... Is there any workaround to avoid using SELECT TYPE everywhere?