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

--- Comment #15 from anlauf at gcc dot gnu.org ---
(In reply to Steve Kargl from comment #13)
> Note 1 in Fortran 2023, Sec. 8.5.3, p. 100, is non-normative
> text.  I suppose one can claim that gfortran should throw an
> error when a function result is marked with the allocatable
> attribute.

You mean when the function result is not allocated in that case?

> Unfortunately, it is likely a catch-22 situation
> in that gfortran needs to know the function result is allocatable
> so it can do the allocaton within the function, but it is not
> an allocatable outside of the function.  Not sure gfortran
> can mark an internal symbol to do both.

I checked how to implement a run-time check for a non-allocated
function result, but did this in the wrong place - in the caller.
This did work when I did allocate and the deallocate before return,
otherwise the result variable is simply undefined, and the check does
not work.

So a run-time check needs to be put where the function return is generated.

Reply via email to