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: [Patch, fortran] PR31879 , PR31197 , PR31258 & PR32703 - various character problems


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


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