From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DA0F439484A0; Wed, 23 Feb 2022 08:59:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA0F439484A0 From: "burnus at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Feb 2022 08:59:19 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104651 --- Comment #3 from Tobias Burnus --- (In reply to kargl from comment #1) > (In reply to Tobias Burnus from comment #0) > > Error: Rank mismatch in argument =E2=80=98x=E2=80=99 at (1) (rank-1 and= rank-2) > > Error: Rank mismatch in argument =E2=80=98y=E2=80=99 at (1) (rank-2 and= rank-1) > > > > subroutine bar(x) > > class(t) :: x(*) > > > > subroutine bar2(y) > > class(t) :: y(5,10) >=20 > Error look correct to me. Interfaces are resolved by type, kind, and ran= k; > 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 =E2=80=93 an= d 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 argu= ment 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 Seque= nce association": "Sequence association only applies when the dummy argument is an explicit-s= hape 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 b= its related to this discussion.=