This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/42112] overloaded function with allocatable result problem
- From: "pault at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 25 Nov 2010 05:58:20 +0000
- Subject: [Bug fortran/42112] overloaded function with allocatable result problem
- Auto-submitted: auto-generated
- References: <bug-42112-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42112
--- Comment #5 from Paul Thomas <pault at gcc dot gnu.org> 2010-11-25 05:58:03 UTC ---
(In reply to comment #4)
>
> This looks correct to me, unless F2003 forces a reallocation in ALLOCATE, when
> frealloc-lhs is in effect?
This is specifically not the case. The standard says, unconditionally, that
the ALLOCATE statement generates and error with an already allocated array.
>
> 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***
I have fixed it for my rellocate on assign patch but a question remains that is
at the core of the original problem:
At trans-array.c:6958
/* Dummy, use associated and result variables don't need anything special.
*/
if (sym->attr.dummy || sym->attr.use_assoc || sym->attr.result)
{
gfc_add_init_cleanup (block, gfc_finish_block (&init), NULL_TREE);
return;
}
ie. deallocation is not done on procedure entry for results. I believe that
this is incorrect for gfortran's pass by reference handling of function
results.
Cheers
Paul