gfortran bug?
Daniel Franke
franke.daniel@gmail.com
Wed Dec 6 20:55:00 GMT 2006
On Wednesday 06 December 2006 21:24, Ray Nachlinger wrote:
> The following program produces strange results.
[snipped program code]
> "repeat" takes the first argument which is len integer*2
> length long and copies it num times to the last argument.
> As far a I can see, all three calls should produce 5
> .true. values. The first two calls, however, produce
> T F T T T. The last one is as I expected. Is this a bug
> or am I confused?
>
> I am using gcc version 4.1.1
$> gfortran-svn -g -Wall ray.f90 && ./a.out
T T T T T
T T T T T
T T T T T
Segmentation fault
$> gfortran-svn -v
gcc version 4.3.0 20061128 (experimental)
Works here in terms of expectations - but crashes afterwards.
Slightly rewritten, making "repeat" a CONTAINed subroutine, I get:
$> gfortran-svn -g -Wall -fbounds-check ray-2.f90
ray-2.f90:7.14:
call repeat(.true.,len_l,n, l(1))
1
Error: Type/rank mismatch in argument 'a' at (1)
ray-2.f90:10.14:
call repeat(lt,len_l,n, l(1))
1
Error: Type/rank mismatch in argument 'a' at (1)
ray-2.f90:14.14:
call repeat(l(1),len_l,n, l(2))
1
Error: Type/rank mismatch in argument 'a' at (1)
(These diagnostics are also given by 4.1.1)
$> cat ray-2.f90
PROGRAM main
integer, parameter :: len_l = 2, n = 5
logical, parameter :: lt = .true.
logical l(n)
call repeat(.true.,len_l,n, l(1))
print *,l
call repeat(lt,len_l,n, l(1))
print *,l
l(1) = .true.
call repeat(l(1),len_l,n, l(2))
print *,l
CONTAINS
subroutine repeat(a,len,num, b)
integer num,len,k,j
integer*2 a(num,*),b(num,*)
do 2100 k = 1, num
do 2100 j = 1, len
b(j,k) = a(j,k)
2100 continue
end subroutine
END PROGRAM
Hope this helps?!
Regards.
Daniel
More information about the Fortran
mailing list