[Bug fortran/102689] Segfault with RESHAPE of CLASS as actual argument
pault at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Nov 29 10:35:09 GMT 2023
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102689
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2023-11-29
CC| |pault at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Paul Thomas <pault at gcc dot gnu.org> ---
Confirmed!
implicit none (type, external)
type t
integer :: i
end type t
integer :: j
integer :: src(100) = [(j, j=1,100)]
class(t), allocatable :: B(:,:,:), D(:)
allocate(t :: B(10,10,1))
B(:,:,:)%i = RESHAPE(src, shape(B))
D = reshape(B, [100])
call class_bar(D)
contains
subroutine class_bar(x)
class(t), intent(in) :: x(:)
integer :: k
if (any (x(:)%i /= [(k, k=1,100)])) error stop 1
end
end
Works as intended. Inspection of the original code reveals:
atmp.19.dtype = {.elem_len=4, .rank=1, .type=5};
atmp.19.dim[0].stride = 1;
atmp.19.dim[0].lbound = 0;
atmp.19.dim[0].ubound = 99;
atmp.19.span = 4;
atmp.19.data = (void * restrict) &A.20;
atmp.19.offset = 0;
_gfortran_reshape (&atmp.19, D.4442, D.4451, 0B, 0B);
class_bar (atmp.19);
ie. The class formal argument is being fed an array descriptor. This is a
problem with gfc_conv_procedure_call.
The discussion about inlining or not is for another day :-)
Thanks for the report, Tobias.
Paul
More information about the Gcc-bugs
mailing list