[Patch,Fortran] Do not auto-deallocate result variable

Tobias Burnus burnus@net-b.de
Tue Sep 23 20:06:00 GMT 2008


Hi all,

this fixes a stupid bug, where gfortran tried to free a result variable.
I do not fully understand why this has not been found earlier as the
code is clearly wrong and the program fails with 4.2, 4.3 and 4.4
with an ICE.

Before the if-block of my patch there is:

  /* Allocatable arrays need to be freed when they go out of scope.
     The allocatable components of pointers must not be touched.  */
  if (sym_has_alloc_comp && !(sym->attr.function || sym->attr.result)
      && !sym->attr.pointer && !sym->attr.save)

where the sym->attr.result case is properly honoured. But five lines
later is was unfortunately missed.

Thanks to Rich Townsend for reporting this bug.

Built and currently check-gfortran'ing on x86-64-linux.
OK for the trunk and 4.3 ?

(Unless there are objections, I plan to commit it as obvious tomorrow.)

Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: result-fix.diff
Type: text/x-patch
Size: 2432 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080923/80fbcba5/attachment.bin>


More information about the Fortran mailing list