public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/104845] New: Wrong array size for component of CLASS array element
@ 2022-03-08 19:50 burnus at gcc dot gnu.org
  2022-03-08 20:08 ` [Bug fortran/104845] " burnus at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-03-08 19:50 UTC (permalink / raw)
  To: gcc-bugs

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)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/104845] Wrong array size for component of CLASS array element
  2022-03-08 19:50 [Bug fortran/104845] New: Wrong array size for component of CLASS array element burnus at gcc dot gnu.org
@ 2022-03-08 20:08 ` burnus at gcc dot gnu.org
  2022-03-09  9:40 ` burnus at gcc dot gnu.org
  2022-04-21 17:26 ` mikael at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-03-08 20:08 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104845

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> ---
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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/104845] Wrong array size for component of CLASS array element
  2022-03-08 19:50 [Bug fortran/104845] New: Wrong array size for component of CLASS array element burnus at gcc dot gnu.org
  2022-03-08 20:08 ` [Bug fortran/104845] " burnus at gcc dot gnu.org
@ 2022-03-09  9:40 ` burnus at gcc dot gnu.org
  2022-04-21 17:26 ` mikael at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-03-09  9:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104845

--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> ---
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug fortran/104845] Wrong array size for component of CLASS array element
  2022-03-08 19:50 [Bug fortran/104845] New: Wrong array size for component of CLASS array element burnus at gcc dot gnu.org
  2022-03-08 20:08 ` [Bug fortran/104845] " burnus at gcc dot gnu.org
  2022-03-09  9:40 ` burnus at gcc dot gnu.org
@ 2022-04-21 17:26 ` mikael at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: mikael at gcc dot gnu.org @ 2022-04-21 17:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104845

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikael at gcc dot gnu.org

--- Comment #3 from Mikael Morin <mikael at gcc dot gnu.org> ---
(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 ?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-21 17:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-08 19:50 [Bug fortran/104845] New: Wrong array size for component of CLASS array element burnus at gcc dot gnu.org
2022-03-08 20:08 ` [Bug fortran/104845] " burnus at gcc dot gnu.org
2022-03-09  9:40 ` burnus at gcc dot gnu.org
2022-04-21 17:26 ` mikael at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).