https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104844
Bug ID: 104844
Summary: CLASS actual to assumed-rank TYPE(*) wrongly passes
declared instead of dynamic type
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
Target Milestone: ---
The following testcase shows that not the dynamic type but the declared type is
passed in the call.
Or rather: It shows that decl->elem_len matches the declared type, I have not
checked the values.
implicit none (type, external)
type t
integer, allocatable :: a(:,:,:), aa
integer :: b(5), c
end type t
type t2
class(t), allocatable :: d(:,:), e
end type t2
type, extends(t2) :: t2e
integer :: q(7), z
end type t2e
type(t2) :: dummy
class(t2), allocatable :: var
allocate (t2e :: var)
print *, sizeof(dummy), sizeof(var) ! prints 112 144
call sz_ar(var, var)
contains
subroutine sz_ar (a, b)
type(*) :: a(..)
class(*) :: b(..)
print *, sizeof(a), sizeof(b) ! prints 112 144 - expected: 144 144
if (sizeof(a) /= sizeof(b)) error stop
end
end