PR fortran/19269 (partial fix): Lengths of reshaped arrays

Richard Sandiford richard@codesourcery.com
Wed Sep 7 07:45:00 GMT 2005


Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de> writes:
> Richard Sandiford wrote:
>> gcc/fortran/
>> 	PR fortran/19269
>> 	* simplify.c (gfc_simplify_transpose): Set the result's typespec from
>> 	the source, not the first element of the return value.
>> 
>> gcc/testsuite/
>> 	PR fortran/19269
>> 	* gfortran.fortran-torture/execute/pr19269-1.c: New test.
>
> This is ok with the testcase modified as discussed.

Thanks.  I went back to using 'a', 'b', 'c' and 'd' from the original PR.
For the record, here's what I checked in.  (I also fixed the name of the
test in the ChangeLog.  Oops!  Looks like I've managed to do that in some
of the other patch submissions too.)

And sorry for the bogus testcase.  I'm a bit worried that it might have
deflected attention from the second problem mentioned in the message:

Richard Sandiford writes:
> To quote from the PR notes, there are now two separate problems:
>
>     First, gfc_simplify_reshape doesn't set the result's typespec
>     correctly (it doesn't include a character length).  Second, we're
>     passing character lengths to the transpose library function, which
>     only wants array descriptors.
>
> Has the second problem already been discussed?  If so, what was the
> outcome?  I suppose it could be fixed by suppressing the length
> arguments or by creating special character versions of the library
> routines.

Does anyone have any thoughts about that?

Richard


gcc/fortran/
	PR fortran/19269
	* simplify.c (gfc_simplify_transpose): Set the result's typespec from
	the source, not the first element of the return value.

gcc/testsuite/
	PR fortran/19269
	* gfortran.fortran-torture/execute/pr19269-1.f90: New test.

--- gcc/fortran/simplify.c	2005-07-10 07:28:06.000000000 +0100
+++ gcc/fortran/simplify.c	2005-09-06 16:29:15.000000000 +0100
@@ -2858,7 +2858,7 @@ inc:
   for (i = 0; i < rank; i++)
     mpz_init_set_ui (e->shape[i], shape[i]);
 
-  e->ts = head->expr->ts;
+  e->ts = source->ts;
   e->rank = rank;
 
   return e;
diff -c /dev/null gcc/testsuite/gfortran.fortran-torture/execute/pr19269-1.f90
*** /dev/null	2005-06-16 22:49:09.000000000 +0100
--- gcc/testsuite/gfortran.fortran-torture/execute/pr19269-1.f90	2005-09-06 17:04:28.000000000 +0100
***************
*** 0 ****
--- 1,16 ----
+ program main
+   call test (reshape ((/ 'a', 'b', 'c', 'd' /), (/ 2, 2 /)))
+ contains
+   subroutine test (a)
+     character (len = *), dimension (:, :) :: a
+ 
+     if (size (a, 1) .ne. 2) call abort
+     if (size (a, 2) .ne. 2) call abort
+     if (len (a) .ne. 1) call abort
+ 
+     if (a (1, 1) .ne. 'a') call abort
+     if (a (2, 1) .ne. 'b') call abort
+     if (a (1, 2) .ne. 'c') call abort
+     if (a (2, 2) .ne. 'd') call abort
+   end subroutine test
+ end program main



More information about the Gcc-patches mailing list