public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/104844] New: CLASS actual to assumed-rank TYPE(*) wrongly passes declared instead of dynamic type
Date: Tue, 08 Mar 2022 19:25:36 +0000	[thread overview]
Message-ID: <bug-104844-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             reply	other threads:[~2022-03-08 19:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-08 19:25 burnus at gcc dot gnu.org [this message]
2022-03-08 20:08 ` [Bug fortran/104844] " burnus at gcc dot gnu.org
2022-03-09  9:40 ` burnus at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-104844-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).