[PATCH] Debug support for Fortran 90 assumed shape and other descriptor using arrays (PR fortran/22244)

Jan Kratochvil jan.kratochvil@redhat.com
Fri Nov 23 19:45:00 GMT 2007


On Fri, 16 Nov 2007 17:36:53 +0100, Tobias Burnus wrote:
> Tobias Burnus wrote:
> > Regarding the test case a4.f90 and a4.f90: I get for x(3,1) with
> > gfortran a "10.0" but with g95, nag f95 and ifort a "4.0", which
> > indicates a bug in gfortran.
> >   
> 
> This is not a bug in gfortran but a bug in the program. A minimal test
> case is:
> 
> program prog
>   implicit none
>   integer :: a(2,2)
>   a = 0
>   call test(transpose(a))
>   print *, a
> contains
>   subroutine test(x)
>     ! intent(out) :: x ! uncommenting this gives a compile error
>     integer :: x(:,:)
>     x = 3
>   end subroutine test
> end program prog
> 
> 
> Here, the question is whether one can assign to "tranpose(a)" or not.
> gfortran does not create a copy of the variable "a" as the other
> compilers seem to do, but works with strides. Therefore, gfortran prints
> "3 3 3 3" and ifort, NAG f95, g95 and openf95 print "0 0 0 0".

The attached sample is right, I hope.  The `call abort' checks are done only
after the subroutine TEST finished, at that time its results must be copied
back into the variable A.

The GDB testcase first calls `finish' TEST before checking the A values.
I understand that for GDB `up' (before TEST finished) nobody guarantees A would
already contain the values as compilers not doing the DW_AT_byte_stride magic
may only copy the values back on the exit from TEST.

INTENT should not be required there as it is an optimization only keyword.


Thanks,
Jan
-------------- next part --------------
program prog
  implicit none
  integer :: a(3, 3)
  a = 3
  call test (a (2:3, 2:3))
  if (a (2, 2) .ne. 4) call abort
  if (a (3, 3) .ne. 5) call abort
contains
  subroutine test (x)
    intent (out) :: x
    integer :: x (:,:)
    x (1, 1) = 4
    x (2, 2) = 5
  end subroutine test
end program prog


More information about the Fortran mailing list