[Bug fortran/69080] No automatic deallocation of allocatable function results

sv.mueller@tu-braunschweig.de gcc-bugzilla@gcc.gnu.org
Tue Dec 29 22:09:00 GMT 2015


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

--- Comment #3 from sv.mueller@tu-braunschweig.de ---
Thanks for testing this out!

Indeed there aren't any leaks with your changes. Actually, leaving the module
save statement uncommented produces the same positive result for me.

However, I don't think this is a solution. If you, for example, think of a
string class as the derived type instead of "dummy", there could be a function
returning an allocatable string_class derived type. This string function result
could be used somewhere in a subroutine as input, but the subroutine doesn't
know if the string will still be used outside of the subroutine. So there is no
way the subroutine should deallocate the string.

I know that allocatables that are declared in the program itself aren't
deallocated automatically because of the implicit save attribute. But my
thinking was that Fortran will take care of deallocating allocatables in all
other cases. Of course, I may be mistaken.


More information about the Gcc-bugs mailing list