Try the following code:
pure subroutine foo
type Book
integer pages(10)
end type
type(Book) :: books(10)
integer i, j
do i = 1, 10
associate (aBook => books(i))
do j = 1, 10
aBook%pages(i) = i
end do
end associate
end do
end subroutine
It gives an error:
Error 1 error #7617: This host associated object appears in a 'defining' context in a PURE procedure or in an internal procedure contained in a PURE procedure.
pure subroutine foo
type Book
integer pages(10)
end type
type(Book) :: books(10)
integer i, j
do i = 1, 10
associate (aBook => books(i))
do j = 1, 10
aBook%pages(i) = i
end do
end associate
end do
end subroutine
It gives an error:
Error 1 error #7617: This host associated object appears in a 'defining' context in a PURE procedure or in an internal procedure contained in a PURE procedure.
連結已複製
2 回應