https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106750

Mikael Morin <mikael at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikael at gcc dot gnu.org

--- Comment #4 from Mikael Morin <mikael at gcc dot gnu.org> ---
Regarding the other "leak" from the original test:

(In reply to federico from comment #0)
> 
> program test
  (...)
>    type(t), allocatable :: ts(:)
  (...)
>    ! [leak #2] happens if ts is not deallocated. Shouldn't a program work
> like a
>    ! subroutine, and deallocate everything that's going out of scope?
>    deallocate(ts)
> 
> end program test
> 

Not automatically deallocating is the correct behavior here, I think:

> A variable, (...) declared in the scoping unit of a main program, module, or
> submodule implicitly has the SAVE attribute
   => TS has the save attribute.

> The SAVE attribute specifies that a local variable of a program unit or 
> subprogram retains its association status, allocation status, definition 
> status, and value after execution of a RETURN or END statement (...).
   => TS is not deallocated at the end of the program

> When the execution of a procedure is terminated by execution of a RETURN or 
> END statement, an unsaved allocatable local variable of the procedure retains
> its allocation and definition status if it is a function result or a
> subobject thereof; otherwise, if it is allocated it will be deallocated.
   => this doesn’t apply as TS has the save attribute.

Reply via email to