This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch, fortran] PR35810 - [TR 15581 / F2003] Automatic reallocation on assignment to allocatable variables


Dear Tobias,

Thanks for taking yet another look and, as I anticipated, finding more
problems :-)


> Reading the code I think you mishandle kind=4 characters as you seem to
> allocate only (char-length) bytes instead of (storage size of an
> element)*(char length). However, when I tries it, I already get a segfault
> with kind=1 characters:
>
> character(kind=1, len=100), allocatable, dimension(:) :: str
> str = [ "abc" ]
> end
>
> Ditto for character kind=4.

This I have fixed and, as a side effect, I nearly have deferred length
characters working too.  I should have been using expr1 as the source
of the character length, not expr2.

>
>
> Additionally, you have lots of checks of the form:
> + ? if (!expr1->symtree->n.sym->attr.allocatable
> + ? ? ? || (expr1->ref && expr1->ref->type == REF_ARRAY
>
> Those fail if you work with derived types such as:
>
> type t
> ?integer, allocatable :: a(:)
> end type t
> type(t) :: x
>
> x%a= [1,2,3]
> print *, x%a
> x%a = [1]
> print * ,x%a
> end
>

I did not touch this because I thought that it was already working.
However, I have now remembered that the automatic allocation only
works when it is the derived type itself on the lhs.  I will make it
so!

Thanks again

Paul


-- 
The knack of flying is learning how to throw yourself at the ground and miss.
? ? ?? --Hitchhikers Guide to the Galaxy


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]