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/104651] [OOP] CLASS with assumed-size/assumed-rank array
Date: Wed, 23 Feb 2022 08:59:18 +0000	[thread overview]
Message-ID: <bug-104651-4-3grt0HGTa3@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-104651-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to kargl from comment #1)
> (In reply to Tobias Burnus from comment #0)
> > Error: Rank mismatch in argument ‘x’ at (1) (rank-1 and rank-2)
> > Error: Rank mismatch in argument ‘y’ at (1) (rank-2 and rank-1)
> >
> > subroutine bar(x)
> >   class(t) :: x(*)
> >
> > subroutine bar2(y)
> >   class(t) :: y(5,10)
> 
> Error look correct to me.  Interfaces are resolved by type, kind, and rank;
> sometimes referred to TKR.  Is there an exception for class?

Passing an array of any rank or even array element to ASSUMED-SIZE and
EXPLICIT-SIZE ARRAYS is a Fortran 66 feature which still exists. For those, the
simple (contiguous) byte stream ("storage sequence") is passed – and the
partition of that stream into array bounds/elements is determined by the
callee.

Example:
    integer A(10), B(10,10), C(10,10,10)
    call foo(A,A); call foo(B,B); call foo(C,C)
  contains
    subroutine foo(x,y)
      integer, intent(in) :: x(5:7,*), y(5,2)
    end
  end

This works just fine in gfortran. But for CLASS the like-wise code does not
work.

>From the standard (allocatable/pointers and deferred-shape arrays are in
section):


Fortran 2018, "15.5.2.4 Ordinary dummy variables":

"If a dummy argument is an assumed-shape array, the rank of the actual argument
shall be the same as the rank of the dummy argument ..."

As this restriction does not exist for assumed-size/explicit-size array
dummies, those are permitted. Some more wording is then in "15.5.2.11 Sequence
association":

"Sequence association only applies when the dummy argument is an explicit-shape
or assumed-size array. The rest of this subclause only applies in that case.
"An actual argument represents an element sequence if it is an array
expression, an array element designator, a default character scalar, or a
scalar of type character with the C character kind (18.2.2). [...]"

For details, see the two sections mentioned above as I did leave out some bits
related to this discussion.

      parent reply	other threads:[~2022-02-23  8:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22 21:24 [Bug fortran/104651] New: " burnus at gcc dot gnu.org
2022-02-22 22:01 ` [Bug fortran/104651] " kargl at gcc dot gnu.org
2022-02-23  8:03 ` burnus at gcc dot gnu.org
2022-02-23  8:59 ` burnus at gcc dot gnu.org [this message]

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-104651-4-3grt0HGTa3@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).