https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69080
--- Comment #8 from Mueller <sv.muel...@tu-braunschweig.de> --- (In reply to Dominique d'Humieres from comment #6) > > 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 allocatable > > in all other cases. Of course, I may be mistaken. > > Well, if the user is unable to decide when and where something should be > deallocate, how can you expect the compiler to do better? AFAIU this should > be handled through finalization, but I am still learning and I am not in > position to give advice in this area. I think, in theory, the compiler could detect something like call some_subroutine(function_returning_allocatable()) to be a potential case for automatic deallocation of the returned allocatable. But, as was pointed out above (if I understood correctly), automatic deallocation of allocatable function results is not part of the standard.