https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85868
--- Comment #5 from Harald Anlauf <anlauf at gmx dot de> ---
Better testcase for debugging:
program pr85858
implicit none
integer, pointer :: t(:)
integer :: i, lb
lb = -1
allocate (t(lb:5))
do i = lb, 5
t(i) = i
end do
call te (t( :)) ! Full array: OK
call te (t(lb:)) ! Array section, but effectively full array: OK
call te (t( 0:)) ! Offset should depend on 0-lb !
call te (t( 1:)) ! Offset should depend on 1-lb !
contains
subroutine te (a)
integer, pointer, intent(in) :: a(:)
print *, a(1) !, lbound (a, dim=1)
end subroutine te
end program
Expected output: four 1s.
Current trunk prints:
1
1
2
3
(Outputs of 7.x and 8.x are also quite strange).
Dump-tree-original shows for the generated descriptors (excerpt):
for call te (t(lb:))
D.3893 = (integer(kind=8)) lb;
parm.3.dim[0].lbound = D.3893;
D.3901 = t.dim[0].stride;
parm.3.data = (void *) &(*(integer(kind=4)[0:] *) t.data)[(D.3893 -
t.dim[0].lbound) * D.3901];
parm.3.offset = t.offset;
for call te (t( 0:))
parm.4.dim[0].lbound = 0;
parm.4.data = (void *) &(*(integer(kind=4)[0:] *)
t.data)[-t.dim[0].lbound * D.3909];
parm.4.offset = t.offset;
while the subroutine references:
(a->data + (sizetype) ((a->offset + NON_LVALUE_EXPR <a->dim[0].stride>) *
a->span))
Can this be right? If .data changes, shouldn't .offset change accordingly?