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: [fortran, patch] Fix PR15959, character array initialization.


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


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