public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pault at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/64290] [F03] No finalization at deallocation of LHS Date: Mon, 11 Jan 2021 08:17:11 +0000 [thread overview] Message-ID: <bug-64290-4-y5ZoYcwoaH@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-64290-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64290 Paul Thomas <pault at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pault at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |pault at gcc dot gnu.org --- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> --- Created attachment 49936 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49936&action=edit Initial fix for the PR Triggered by a recent thread on clf, I have made a first stab at this PR. This patch is thus far perfect and has the following regressions: FAIL: gfortran.dg/class_optional_1.f90 -O0 execution test FAIL: gfortran.dg/dynamic_dispatch_6.f03 -O1 execution test FAIL: gfortran.dg/finalize_15.f90 -O0 (internal compiler error) FAIL: gfortran.dg/finalize_25.f90 -O0 execution test FAIL: gfortran.dg/finalize_29.f08 -O0 execution test plus FAIL: gfortran.dg/prof/dynamic_dispatch_6.f03 execution, -fprofile-generate -D_PROFILE_GENERATE which is not too bad for a first attempt. Note that for arrays, finalization is occurring before reallocation of the lhs contrary to the requirements of the standard. This test, based on the reporter's testcase, works as intended: module testmode implicit none type :: simple integer :: ind contains final :: destruct1, destruct2 end type simple integer :: check_scalar integer :: check_array(2) integer :: final_count = 0 contains subroutine destruct1(self) type(simple), intent(inout) :: self ! print *, "DESTRUCTING SCALAR", self%ind check_scalar = self%ind check_array = 0 final_count = final_count + 1 end subroutine destruct1 subroutine destruct2(self) type(simple), intent(inout) :: self(:) ! print *, "DESTRUCTING ARRAY", self%ind check_scalar = 0 check_array = self%ind final_count = final_count + 1 end subroutine destruct2 subroutine test (cnt, scalar, array, off) integer :: cnt integer :: scalar integer :: array(:) integer :: off if (final_count .ne. cnt) stop 1 + off if (check_scalar .ne. scalar) stop 2 + off if (any (check_array .ne. array)) stop 3 + off end subroutine test end module testmode program test_final use testmode implicit none type(simple), allocatable :: myres, myres2 type(simple), allocatable :: myarray(:) type(simple) :: thyres = simple(21), thyres2 = simple(22) allocate(myres) allocate(myres2) myres%ind = 1 myres2%ind = 2 myres = myres2 call test(1, 1, [0,0], 10) allocate(myarray(2)) myarray%ind = [42, 43] myarray = [thyres, thyres2] call test(2, 0, [42,43], 20) thyres2 = simple(99) call test(3, 22, [0,0], 30) thyres = thyres2 call test(4, 21, [0,0], 40) deallocate (myres, myres2) call test(6, 2, [0,0], 100) deallocate (myarray) call test(7, 0, [21,22], 200) end program test_final Paul
next prev parent reply other threads:[~2021-01-11 8:17 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-12-12 16:26 [Bug fortran/64290] New: Destructor not called " baradi09 at gmail dot com 2014-12-15 11:46 ` [Bug fortran/64290] [F03] No finalization " janus at gcc dot gnu.org 2021-01-11 8:17 ` pault at gcc dot gnu.org [this message] 2021-01-12 12:04 ` pault at gcc dot gnu.org 2021-01-12 13:03 ` drikosev at gmail dot com 2021-01-18 8:32 ` drikosev at gmail dot com 2021-05-04 12:31 ` rguenth at gcc dot gnu.org 2022-12-16 9:28 ` drikosev at gmail dot com 2023-03-18 7:56 ` cvs-commit at gcc dot gnu.org 2023-03-18 12:23 ` pault 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-64290-4-y5ZoYcwoaH@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: linkBe 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).