[Patch, fortran-dev] ALLOCATE statements with CLASS variables

Janus Weil janus@gcc.gnu.org
Wed Sep 23 20:57:00 GMT 2009


>> 1) "ALLOCATE (x, SOURCE=y)" does not work correctly if y is a CLASS.
>> In this case the the size of the allocated block must be determined at
>> runtime (and is then basically the size of y, which is: the size of
>> the dynamic type of y). I have not managed to put this correctly into
>> gfc_trans_allocate yet. If anyone known how to do this, let me know.
>
> One slightly evil and very kludgy temporary fix would be to enclose it
> in a SELECT TYPE (y)....?

Nah, I don't like this idea very much. I was more thinking of
something like this:

We have an intrinsic function SIZEOF (which is a GNU extension, but
that does not matter), so couldn't we just insert code to call this,
with 'y' as the argument, and use the result as the size to allocate?
Problem is: I can't figure out how to do this properly ...

Cheers,
Janus



More information about the Fortran mailing list