Created attachment 52585 [details] 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)
Part of the testcase is part of the patch at: https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591414.html When this PR is fixed (and that patch is committed): Please uncomment the commented lines.
Mentioned patch was committed as r12-7558-ga5c9b7c4f95ef77b83da82241cabdf80d8b1cad5 Thus, when this PR is fixed, please uncomment the respective lines in gcc/testsuite/gfortran.dg/sizeof_6.f90
(In reply to Tobias Burnus from comment #0) > > 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) ct2a(5,3,2)%d isn’t allocated, should it be ct2a(5,4,2)%d ?