This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [fortran, patch] Fix PR15959, character array initialization.
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: Feng Wang <wf_cs at yahoo dot com>
- Cc: Steven Bosscher <stevenb at suse dot de>, fortran at gcc dot gnu dot org,gcc-patches at gcc dot gnu dot org
- Date: Fri, 01 Apr 2005 21:20:58 +0200
- Subject: Re: [fortran, patch] Fix PR15959, character array initialization.
- References: <20050401130139.12283.qmail@web15602.mail.cnb.yahoo.com>
Feng Wang wrote:
> Yes, it is a really question. In fact we now don't pad parameter string. But I
> think it is another bug. Example follows:
>
> character(len = 10),parameter:: a = 'hello'
> print *, a, "world"
> end
>
> And I report this bug as PR20713.
Hm, I think I ran into this a few weeks ago, but it seems like I didn't open a
PR for it.
This problem suggests that your patch is either incomplete or attacks the
problem too late in the compilation chain. Because this new problem is
related to constant folding (i.e. 'a' in the print statement gets expanded to
the literal string "hello" instead of the correct "hello "), it is clear
that at the time of constant folding the string length in this example hasn't
been verified. IOW I think it would be preferable if a fix to PR 15959 fixed
PR 20713 along the same way.
WRT to the question Steven asked, gfc_conv_string_init takes care of string
lengths when building the initializers.
(I'm sorry that I don't have time to dig out the necessary details of how
constant folding and resolution interact to suggest a better fix.)
- Tobi