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

pault at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Nov 25 08:02:00 GMT 2010


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



More information about the Gcc-bugs mailing list