https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127413
Bug ID: 127413
Summary: Array pointer assignment doesn't correctly set the
element length
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: mikael at gcc dot gnu.org
Target Milestone: ---
This comes from the analysis in PR127233 comment #5.
Testcase:
program prog
implicit none
integer, parameter :: k = 2
integer, parameter :: n = 5
type :: t1
integer(kind=k) :: c1, c2
end type
type, extends(t1) :: t2
integer(kind=k) :: c3
end type
type(t2), target :: x(n)
class(t1), pointer :: y(:)
y => x
call sub(y)
contains
subroutine sub(arg)
type(*), intent(in) :: arg(:)
print *, sizeof(arg)
!if (sizeof(arg) /= k * n * 3) error stop 1
end subroutine
end program
It shows as output:
20
Expected output:
30
The pointer assignment shows in the dump as:
y._vptr = (struct __vtype_prog_T1 * {ref-all}) &__vtab_prog_T2;
y._data.span = 6;
y._data.dtype = {.elem_len=4, .version=0, .rank=1, .type=5};
y._data.dim[0].lbound = 1;
y._data.dim[0].ubound = 5;
y._data.dim[0].stride = 1;
y._data.data = (void *) &x[0];
y._data.offset = -1;
The dtype assignment sets the element length to 4 instead of 6.