[Patch, Fortran, F03] PR 55603: Memory leak with scalar allocatable function result

Tobias Burnus burnus@net-b.de
Mon Sep 2 20:00:00 GMT 2013


Am 27.08.2013 15:09, schrieb Janus Weil:
> here is a patch for PR 55603, which plugs a memory leak with scalar
> allocatable function results.
>
> To accomplish this, several things are done:
> 1) Allocatable scalar function results are passed as argument now and
> returned by reference (just like array or character results, cf.
> gfc_return_by_reference).
[...]
> In fact the patch is just a first step and does not handle more
> advanced cases yet (like polymorphic allocatable scalar results,
> finalization, etc).

Hooray an ABI breakage! (On the other hand, the finalizer already causes 
some breakage - but this is worse as with an interface, one can override 
the .mod-version check.)

In my attempts to get this working, I kept the current version - but 
handled derived types and non-derived types separately. The reason was 
that functions can occur everywhere but DT/CLASS can only occur at some 
places. On the other hand, DT/CLASS can have allocatable components and 
all other kind of nasty things - and se->post comes too early for that. 
For some reasons, it seems to work if there are no allocatable 
components and other nastiness.

I am not sure which approach is better.  In any case, here is my current 
draft - completely unclean and not touched for about a month. And of 
course not ready/fully working. (Otherwise, I had posted a patch.)

I have not yet looked at your patch - and I will first look through the 
backlog of gfortran emails/patches before returning to this one.

Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dealloc-scalar.diff
Type: text/x-patch
Size: 5952 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20130902/c2ea8ff0/attachment.bin>


More information about the Fortran mailing list