[PATCH, gfortran] Fix initialization of arrays of strings
Feng Wang
wf_cs@yahoo.com
Tue Jul 12 00:33:00 GMT 2005
--- Steve Kargl <sgk@troutmask.apl.washington.edu>ôµÃ:
> On Tue, Jul 12, 2005 at 01:13:52AM +0800, Feng Wang wrote:
> > --- Steve Kargl <sgk@troutmask.apl.washington.edu>????:
> >
> >> On Mon, Jul 11, 2005 at 02:40:01PM +0800, Feng Wang wrote:
> >>> I think we should fix this in array.c
> >>> (resolve_character_array_constructor).
> >>> This is earlier than add_init_expr_to_sym. And we should also add
> >>> it to the gfc_current_ns->cl_list to void memory leak. The list
> >>> will be deallocated with the namespace.
> >>>
> >>
> >> I don't understand what you want to do. I just watched the
> >> compiler go through resolve_character_array_constructor
> >> and gfc_set_constant_character_len and it appears to do want
> >
> > Yes, it go through resolve_character_array_constructor.
> > 1. I think it is resolve_character_array_constructor that does
> > not allocate character length struct compiling this test and
> > cause ICE in add_init_expr_to_sym.
>
> module z
> integer :: i
> character(6) :: a(2) = (/ ('main ' , i = 1, 2) /) ! ICE.
> character(6) :: b(2) = (/ 'abcd ' , 'efghij' /) ! Compiles fine.
> end module
>
> In the case of b(2), everthing works as expected. That is, memory is
> allocated during the resolve_character_array_constructor call. In the
> a(2) case we get an ICE because the implied-do-loop is not expanded
> in resolve_character_array_constructor, only memory for 1 copy of
> 'main ' is allocated. The implied-do-loop is expanded in
> add_init_expr_to_sym and additional memory is allocated to propagate
> a copy of 'main ' to all elements of a(2).
All the 'main ' memory is allocated during gfc_set_constant_character_len
call. I mean that resolve_character_array_constructor does not call
gfc_get_charlen to set ts.cl if the constractor's expr is not of EXPR_CONSTANT
(a(2)). This cause an ICE when invoking gfc_free_expr (init->ts.cl->length) in
add_init_expr_to_sym. The memory I said is the memory of (gfc_charlen).
>
> > 2. When invoking gfc_get_charlen, we should add its result to
> > gfc_current_ns->cl_list. In the gfc_get_charlen, we get some
> > memory. Add it to the list, it will be freed when its namespace
> > is deallocated.
>
> This is not important for my patch and this ICE. Shouldn't gfc_get_charlen
> add its result to gfc_current_ns->cl_list instead of the calling routine?
>
I also think this would be better.
Best Regards,
Feng Wang
--
Creative Compiler Research Group,
National University of Defense Technology, China.
___________________________________________________________
ÃÃ
ȢÃâ·ÃGÃÃÃä£ÂÃùúµÃû¾øÃÃì»øÃüþçÃÃ
³¬´óÃÃÃä
http://cn.mail.yahoo.com/?id=77071
More information about the Gcc-patches
mailing list