public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/65347] New: Final subroutine are not called
@ 2015-03-08 13:31 eddyg_61-bugzilla at yahoo dot it
2015-03-20 9:09 ` [Bug fortran/65347] [F03] Final subroutine not called for function result janus at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: eddyg_61-bugzilla at yahoo dot it @ 2015-03-08 13:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65347
Bug ID: 65347
Summary: Final subroutine are not called
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: eddyg_61-bugzilla at yahoo dot it
In the following program the final subroutine are not called
module testfin_mod
implicit none
type tfin
integer :: t = -1
contains
final :: del_tfin
final :: del_tfinv
end type
contains
function Ctfin(s) result(this)
integer,intent(in) :: s
type(tfin) :: this
this % t = s
end function
subroutine del_tfin(this)
type(tfin), intent(inout) :: this
print *,"Finalized", this % t
end subroutine
subroutine del_tfinv(this)
type(tfin), intent(inout) :: this(:)
print *,"Finalized vector", this % t
end subroutine
subroutine printsomev(a)
type(tfin) :: a(:)
print *,'PRV:', a
end subroutine
subroutine printsomes(a)
type(tfin) :: a
print *,'PRS:', a%t
end subroutine
subroutine pluto
type(tfin),save :: a(3)
call printsomev([a(2), a(1), a(3)])
call printsomev([a(2), Ctfin(10), a(3)])
call printsomes(Ctfin(11))
end subroutine
end module
program test1
use testfin_mod
implicit none
call pluto
end program
The standard (as far as I know) requires the temporary variables corresponding
to Ctfin(10) and Ctfin(11) to be finalized after the end of the subroutines
printsomev and printsomev.
But no finalization take places.
The compiler ifort 13.0.1 correctly calls the final procedures.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/65347] [F03] Final subroutine not called for function result
2015-03-08 13:31 [Bug fortran/65347] New: Final subroutine are not called eddyg_61-bugzilla at yahoo dot it
@ 2015-03-20 9:09 ` janus at gcc dot gnu.org
2022-04-02 0:47 ` damian at archaeologic dot codes
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: janus at gcc dot gnu.org @ 2015-03-20 9:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65347
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2015-03-20
CC| |janus at gcc dot gnu.org
Blocks| |37336
Summary|Final subroutine are not |[F03] Final subroutine not
|called |called for function result
Ever confirmed|0 |1
--- Comment #1 from janus at gcc dot gnu.org ---
Confirmed. See also PR 37336 comment 27. This is case (b).
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/65347] [F03] Final subroutine not called for function result
2015-03-08 13:31 [Bug fortran/65347] New: Final subroutine are not called eddyg_61-bugzilla at yahoo dot it
2015-03-20 9:09 ` [Bug fortran/65347] [F03] Final subroutine not called for function result janus at gcc dot gnu.org
@ 2022-04-02 0:47 ` damian at archaeologic dot codes
2023-03-18 15:06 ` pault at gcc dot gnu.org
2023-04-14 13:59 ` pault at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: damian at archaeologic dot codes @ 2022-04-02 0:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65347
Damian Rouson <damian at archaeologic dot codes> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |damian at archaeologic dot codes
--- Comment #3 from Damian Rouson <damian at archaeologic dot codes> ---
I suspect the code below is a simpler reproducer (25 lines) of this bug
% cat missing-finalization.f90
module object_m
implicit none
type object_t
contains
final :: count_finalizations
end type
contains
subroutine count_finalizations(self)
type(object_t) self
print *,"finalization"
end subroutine
function new_object()
type(object_t) new_object
end function
end module
use object_m
implicit none
type(object_t) object
object = new_object()
end
% gfortran missing-finalization.f90
% ./a.out
% gfortran --version
GNU Fortran (Homebrew GCC 11.2.0_3) 11.2.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/65347] [F03] Final subroutine not called for function result
2015-03-08 13:31 [Bug fortran/65347] New: Final subroutine are not called eddyg_61-bugzilla at yahoo dot it
2015-03-20 9:09 ` [Bug fortran/65347] [F03] Final subroutine not called for function result janus at gcc dot gnu.org
2022-04-02 0:47 ` damian at archaeologic dot codes
@ 2023-03-18 15:06 ` pault at gcc dot gnu.org
2023-04-14 13:59 ` pault at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pault at gcc dot gnu.org @ 2023-03-18 15:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65347
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |pault at gcc dot gnu.org
--- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> ---
This is partially fixed on mainline and behaves in the same way as nagfor.
Finalization of array and stucture constructors is removed in F2018 and so are
only activated by -std=f2003/8 in gfortran. ifort activates both be default. I
seem to have overlooked finalization of structure constructors or functions
within array constructors. I'll have a look to see why it is not working.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/65347] [F03] Final subroutine not called for function result
2015-03-08 13:31 [Bug fortran/65347] New: Final subroutine are not called eddyg_61-bugzilla at yahoo dot it
` (2 preceding siblings ...)
2023-03-18 15:06 ` pault at gcc dot gnu.org
@ 2023-04-14 13:59 ` pault at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pault at gcc dot gnu.org @ 2023-04-14 13:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65347
Paul Thomas <pault at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #5 from Paul Thomas <pault at gcc dot gnu.org> ---
I am closing this as fixed.
The original testcase output now agrees with nagfor. The testcase of comment #3
produces the same output as nagfor and ifort. ifort finalizes the function call
Ctfin(10) in the original testcase, which is certainly not required by the
F2018 standard and was explicitly deleted in a revision to the F2008 standard.
Finalization of structure and array constructors is all over the place with the
different compilers. I therefore am taking the view that complying with F2018
is the best that can be hoped for.
Sorry this has taken so long to address.
Paul
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-04-14 13:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-08 13:31 [Bug fortran/65347] New: Final subroutine are not called eddyg_61-bugzilla at yahoo dot it
2015-03-20 9:09 ` [Bug fortran/65347] [F03] Final subroutine not called for function result janus at gcc dot gnu.org
2022-04-02 0:47 ` damian at archaeologic dot codes
2023-03-18 15:06 ` pault at gcc dot gnu.org
2023-04-14 13:59 ` pault at gcc dot gnu.org
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).