This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, fortran] PR35810 - [TR 15581 / F2003] Automatic reallocation on assignment to allocatable variables
- From: Paul Richard Thomas <paul dot richard dot thomas at gmail dot com>
- To: Tobias Burnus <burnus at net-b dot de>
- Cc: Dominique Dhumieres <dominiq at lps dot ens dot fr>, fortran at gcc dot gnu dot org, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 21 Nov 2010 11:05:52 +0100
- Subject: Re: [Patch, fortran] PR35810 - [TR 15581 / F2003] Automatic reallocation on assignment to allocatable variables
- References: <AANLkTim7ChiQB+Hzf-Pit4GSRh7idofZA5doH5-nxhj9@mail.gmail.com> <4CE8D51A.8080702@net-b.de>
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