From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 21A343857C40; Wed, 10 Aug 2022 07:45:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 21A343857C40 From: "tkoenig at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/106576] New: Finalization of temporaries from functions not occuring Date: Wed, 10 Aug 2022 07:45:27 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: tkoenig 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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, 10 Aug 2022 07:45:28 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106576 Bug ID: 106576 Summary: Finalization of temporaries from functions not occuring Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: tkoenig at gcc dot gnu.org Target Milestone: --- Test case: $ cat g2.f90 module y implicit none type foo integer :: n contains final :: cleanup end type foo interface assignment (=3D) module procedure assign end interface assignment (=3D) contains subroutine assign (rop, op) type(foo), intent(inout) :: rop type(foo), intent(in) :: op rop%n =3D op%n + 1 print '(A12,I3)',"assign", rop%n end subroutine assign function to_foo(n) result(res) integer, intent(in) :: n type (foo) :: res res%n =3D n print '(A12,I3)', "to_foo", res%n end function to_foo subroutine cleanup (self) type (foo), intent(inout) :: self print '(A12,I3)', "cleanup", self%n end subroutine cleanup end module y program memain use y implicit none call chk contains subroutine chk type (foo) :: a a =3D to_foo(3) end subroutine chk end program memain $ gfortran g2.f90 && ./a.out to_foo 3 assign 4 cleanup 4 $ nagfor g2.f90 && ./a.out NAG Fortran Compiler Release 7.1(Hanzomon) Build 7101 [NAG Fortran Compiler normal termination] to_foo 3 assign 4 cleanup 3 cleanup 4 NAG is in fact correct, the temporary from the function results should also be finalized. This actually blocks my little FMPFR library, so I might have a stab at this myself.=