https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109500
--- Comment #6 from anlauf at gcc dot gnu.org --- (In reply to Leandro Lupori from comment #5) > Ok, thanks for the detailed explanations. Now I see that the standard > doesn't allow the return of an unallocated value. This can be closed as > invalid. > > But may I just ask a last related question? As mentioned in the last comment > and according to Note 1 in F2018 8.5.3 ALLOCATABLE attribute, the result of > referencing a function cannot be used as an allocatable argument. The precise text is: "... The result of referencing a function whose result variable has the ALLOCATABLE attribute is a value that does not itself have the ALLOCATABLE attribute." So you can add e.g. allocate (f, source=42) to the body of f to define the result, and then use it as e.g. integer, allocatable :: p p = f() print *, allocated (p) I am still trying to find the exact place in the standard that explains whether - with the corrected f - the following is legal: print *, is_allocated(f()) > This is > however allowed by gfortran (and ifort), with the exception of intrinsic > procedures, and seems to work correctly. Should this be considered an > extension or does it just work by accident and there are no guarantees at > all when using it? I think we are in dangerous waters here. If something appears to work empirically with one compiler, that does not guarantee anything. So as already discussed, if the allocation status of the result cannot be guaranteed, better use a subroutine.