The following programs shows that the automatic deallocation is not applied to
allocatable INTENT(OUT) scalar dummies. It works for array arguments.

Note: For optional arguments, one needs to make sure that the deallocation only
happens if the variable is present, cf. PR 41850.

program test
  implicit none
  integer, allocatable :: a
  allocate(a)
  call foo(a)
  if(.not. allocated(a)) call abort()
  if (a /= 5) call abort()
contains
  subroutine foo(a)
    integer, allocatable, intent(out) :: a
    if(allocated(a)) call abort()
    allocate(a)
    a = 5
  end subroutine foo
end program test


-- 
           Summary: wrong-code: No auto-deallocation for INTENT(OUT)
                    allocatable scalars
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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

Reply via email to