https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128357
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> ---
(In reply to Steve Kargl from comment #3)
> The Fortran standard does require a 'deallocate(i)' before the
> 'end program' statement.
You mean, ... does NOT require ..., maybe?
> (To me,) the above valgrind output
> appears to a false positive in the leak summary.
Well, because of the way we implement a fortran program as a separate procedure
called from main, the pointer _is_ lost at the time the program exits from
main. The tool is right to report it; the pointer is lost at the time the
procedure foo() returns.
But I agree it is not a leak in the sense that the variable is still live at
the end of the fortran program.
>
> So, in your example code, you have 'call sq ((q), zs)'. The
> temporary variable lives in the namespace of the main program.
> When the program ends, there is no leak in that the Fortran
> standard does require one to clean up allocated memory.
This is different because there is no explicit variable keeping the pointer
live until the program ends. The temporary variable is an implementation
detail, and it is there only for the duration of the call. I think a memory
release is required here.
The call is the last statement before the end of the program, and I think it
makes things more confusing. What if the call is in a loop, of say 1000
iterations. Can we keep accumulating temporary variables without freeing them?