This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, fortran] PR31879 , PR31197 , PR31258 & PR32703 - various character problems
- From: Tobias Burnus <burnus at net-b dot de>
- To: Paul Thomas <paulthomas2 at wanadoo dot fr>
- Cc: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>, FX Coudert <fxcoudert at gmail dot com>, "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>, gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 30 Aug 2007 23:20:48 +0200
- Subject: Re: [Patch, fortran] PR31879 , PR31197 , PR31258 & PR32703 - various character problems
- References: <339c37f20708300728p6b810bd8id1927ba211ef9322@mail.gmail.com> <46D70DB8.5000503@wanadoo.fr>
Paul Thomas wrote:
> It should be noted that, although PR32703 is fixed, the code that is
> generated is not correct. Try:
>
> program array_char
> implicit none
> character (len=2) :: x, y
> x = "a "
> y = "cd"
> print*,[trim(x),trim(y)]
> end program array_char
NAG f95 prints for that program (at run time):
Unequal character lengths (2 and 1) in array constructor
and g95:
Fortran runtime error: Inconsistent string size in array constructor
ifort, sunf95 and gfortran accept it and print
acd
openf95 also accepts it but prints
ac
(if one changes the program to x="ab"; y="c " then ifort/sunf95/gfortran
print "ac" and openf95 prints "abc")
Thus I don't see anything which goes wrong. One could consider to add a
check for this with -fbounds-check, but I think the current output is ok
and sensible (for this input). Or what was the expected output?
> Regtested on Cygwin_NT/amd64 and declared cp2k proof by Tobias - OK
> for trunk?
OK. Though I don't know whether you still want to wait for the comments
of others, e.g., of FX.
Of Tobias Schlüter's comments the following was not addressed:
+ for (; char_ref; char_ref = char_ref->next)
+ if (char_ref->type == REF_SUBSTRING)
+ break;
He wrote: "Further, it probably makes sense to assert that the reference
is indeed the last in the chain. "
Paul's reply was: "(ii) I will change the initialization of the loop and
assert that the REF_SUBSTRING is the last in the chain - I actually
removed this assert because it seems to be caught further upstream.
However, it canot do any harm"
I think it is ok like thus, but I would also not oppose if an assert
will be added.
Tobias