From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 475973858001; Thu, 7 Oct 2021 16:08:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 475973858001 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/102641] Bogus error for intent(out) dummy that is a polymorphic assumed-rank array Date: Thu, 07 Oct 2021 16:08:01 +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: 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: cc 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: Thu, 07 Oct 2021 16:08:01 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102641 Tobias Burnus changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |burnus at gcc dot gnu.org --- Comment #1 from Tobias Burnus --- The issue with the code in comment 0 is that GCC has in resolve.c's resolve_symbol: if (sym->ts.type =3D=3D BT_DERIVED .... if ((!a->save && !a->dummy && !a->pointer ... apply_default_init (sym); and likewise a few lines below for BT_CLASS. As there is now code which references the dummy variable, the error Assumed-rank variable y at (1) may only be used as actual argument is shown. * * * And in a similar vain, the following produces an ICE. It is quite similar but as it uses an allocatable component, the code is generated after resolving the symbols - such that an ICE and not a bogus error is the result: module m implicit none (type, external) type t integer, allocatable :: x end type t contains subroutine foo(x) type(t), intent(out) :: x(..) end end Note: C839 (=E2=86=92 PR 54753) prevents some odd corner cases (involving a= ssumed size arrays). One way to handle it would be to handle it in the caller and not in the cal= lee. However, this still requires support for assumed-rank as the following shou= ld be valid: subroutine foo(x) type(t), intent(out) :: x(..) ... subroutine bar(y) type(t), allocatable :: y(..) call foo(x) (y has to be either allocatable or a pointer in order not to violate C839.) As the issue with finalization, polymorphism, allocatable components and default initialization cannot occur with BIND(C), there is no issue if foo = or bar is BIND(C).=