https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88685
Bug ID: 88685
Summary: 8/9 regression] pointer class array argument indexing
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: antony at cosmologist dot info
Target Milestone: ---
Created attachment 45333
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45333&action=edit
Test case
This code works in 7.3.1, but gives wrong answers in 8.3.1 and trunk (outputs
should all be the same, but are not):
program tester
implicit none
Type TArr
integer, allocatable :: CL(:)
end Type TArr
type(TArr), allocatable, target :: arr(:,:)
class(TArr), pointer:: Cls(:,:)
integer i
allocate(arr(1,1))
allocate(arr(1,1)%CL(3))
arr(1,1)%CL=-1
cls => arr
call doit(cls)
contains
subroutine doit(cls)
class(TArr), pointer :: Cls(:,:)
cls(1,1)%CL(:) = 1
print *, 'CL = ', Cls(1,1)%CL
print *, 'CL(i)= ', Cls(1,1)%CL(1),Cls(1,1)%CL(2),Cls(1,1)%CL(3)
end subroutine doit
end program tester
A longer variation is attached that's closer to real case where I found it. It
can give rise to very hard-to-trace bugs, in my full real-world code it showed
up as a mysterious seg fault in random places.
Looks similar to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87336, but is not
fixed in nightly build.