https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104845
Bug ID: 104845
Summary: Wrong array size for component of CLASS array element
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: ---
Created attachment 52585
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52585&action=edit
Testcase (test.f90)
The attached testcase has:
type t2
class(t), allocatable :: d(:,:)
end type t2
which is allocated as:
allocate (t :: var%ct2%d(3,2), var%ct2a(5,4,2)%d(3,2))
allocate (t :: cvar%ct2%d(3,2), cvar%ct2a(5,4,2)%d(3,2))
Thus, the expected array size is 3*2 = 6. However, the result is
6 0 6 0
for
print *, size(var%ct2%d), size(var%ct2a(5,3,2)%d), &
size(cvar%ct2%d), size(cvar%ct2a(5,3,2)%d)
where 'ct2' is scalar
and 'ct2a(5,3,2)' is an array element (also scalar)