Hello,
i got an error with the XE17.1 compiler. The following code produces two different crashes in line 35 (coming from 68), dependend on the type of "vec" in "T_VECTOR". The code worked with the XE16.X compilers.
module M_T_VECTOR
implicit none
type :: T_VECTOR
!forrtl: severe (408): fort: (7): Attempt to use pointer ASSIGN_SOURCE when it is not associated with a target
real :: vec(1:3) = [0.0,0.0,0.0]
!forrtl: severe (157): Program Exception - access violation
! doubleprecision :: vec(1:3) = [0.0,0.0,0.0]
contains
procedure :: assignTo
generic :: assignment(=) => assignTo
procedure ::add
generic :: operator(+) => add
end type T_VECTOR
type, extends(T_VECTOR) :: T_VECTOR_EXT
type(T_VECTOR), allocatable :: disp(:)
class(T_VECTOR_EXT), pointer :: pt_a => null()
class(T_VECTOR_EXT), pointer :: pt_b(:) => null()
end type T_VECTOR_EXT
!--------------------------------------------------------
contains
elemental subroutine assignTo(assign_target, assign_source)
class(T_VECTOR), intent(inout) :: assign_target
class(T_VECTOR), intent(in ) :: assign_source
! Exception thrown here
assign_target%vec = assign_source%vec
end subroutine
elemental function add(lhs, rhs) result(ergebnis)
class(T_VECTOR), intent(in ) :: lhs, rhs
type(T_VECTOR) :: ergebnis
ergebnis%vec = lhs%vec + rhs%vec
end function
end module M_T_VECTOR
!========================================================
program main
use M_T_VECTOR
implicit none
type(T_VECTOR_EXT), target :: a,b(2)
a%pt_b => b
a%pt_a => a
allocate(a%disp(2))
allocate(b(1)%disp(2))
allocate(b(2)%disp(2))
!This works
a%pt_a%disp(1) = a%pt_a%disp(1) + a%pt_b(1)%disp(1)
a%pt_a%disp(2) = a%pt_a%disp(2) + a%pt_b(1)%disp(2)
!This crashes
a%pt_a%disp(:) = a%pt_a%disp(:) + a%pt_b(1)%disp(:)
end program
Greetings
Wolf