[Bug fortran/42112] overloaded function with allocatable result problem

pault at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Nov 21 12:19:00 GMT 2010


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42112

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pault at gcc dot gnu.org

--- Comment #4 from Paul Thomas <pault at gcc dot gnu.org> 2010-11-21 11:41:13 UTC ---
(In reply to comment #0)

> Fortran runtime error: Attempting to allocate already allocated array 'j'
> 
....snip....

>    allocate(loc_ar(1))
>    loc_ar = gen_g() ! does not work
>    !loc_ar = g() ! no problem here
>    deallocate(loc_ar)
>  end function f
> 
>  pure function g() result(j)
>   integer, allocatable :: j(:)
>    allocate( j(1) )
>    j = 2
>  end function g

This looks correct to me, unless F2003 forces a reallocation in ALLOCATE, when
frealloc-lhs is in effect?

I will look tonight, unless somebody beats me to it.

If the first allocate is omitted, the code compiles..... but not with my patch.
****shucks***

Paul



More information about the Gcc-bugs mailing list