http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59694

            Bug ID: 59694
           Summary: no finalization of an unused variable
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rouson at stanford dot edu

With the current trunk, the final subroutine is not invoked when the variable
"bar" goes out of scope in the following code:

localhost:~ rouson$ cat final.f90 
module foo_module
  implicit none
  type foo
  contains
    final :: hello
  end type
contains
  subroutine hello(this)
    type(foo) :: this
    print *,"Hello from finalizer."
  end subroutine
end module
program main
  use foo_module
  implicit none
  block
    type(foo) :: bar
  end block
end program
localhost:~ rouson$ /usr/local/bin/gfortran final.f90 
localhost:~ rouson$ ./a.out
localhost:~ rouson$ /usr/local/bin/gfortran --version
GNU Fortran (GCC) 4.9.0 20140104 (experimental)
Copyright (C) 2014 Free Software Foundation, Inc.

While this behavior seems reasonable at high optimization levels, I believe the
final subroutine should at least be invoked for the default optimization level.
 The NAG compiler invokes the final subroutine.

Damian

Reply via email to