[PATCH] Debug support for Fortran 90 assumed shape and other descriptor using arrays (PR fortran/22244)
Tobias Burnus
burnus@net-b.de
Fri Nov 16 16:58:00 GMT 2007
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".
Turning on all debugging, NAG f95 prints at run time:
Dummy argument X is associated with an expression - cannot assign
And all compiler reject this example if one adds "INTENT(OUT)" for the
dummy "x" in "test".
Thus: If the example is for the test suite, please fix it. One way to do
so is to change the subroutine into a function and returning the
function. Or doing "x = tranpose(x)" before the call or ...
Tobias
More information about the Fortran
mailing list