The G95 compiler does not provide a meaningfull error message (if at all...) when array boundaries are exceeded at runtime. Compiling with -ftrace=full does not change anything.
In addition, the generated executable exhibits different behavior depending on how exactly the code is written although it should apparently not play a role. The bug was tested in MS Windows XP and 2000. The compiler package was the latest self-extracting Windows x86 version (2007-04-10 14:02).
Below are 3 simple programs. The difference between the two first programs is the way the array is initialized. In both cases the array bounds are exceeded in the same way. However, in the first case no error is generated (the extra element is neglected), while in the second case the exception is reported as "Access Violation", and the program crashes. The third program is identical to the second, but with a smaller array. Again the array bounds are exceeded by one element. This time no error is generated and the output is identical to the first case.
Evangelos Bertakis
------------------------------------
integer:: i,array(10)=0
do i=1,11
array(i)=i
write(*,*)array
end do
end
OUTPUT:
1 0 0 0 0 0 0 0 0 0
1 2 0 0 0 0 0 0 0 0
1 2 3 0 0 0 0 0 0 0
1 2 3 4 0 0 0 0 0 0
1 2 3 4 5 0 0 0 0 0
1 2 3 4 5 6 0 0 0 0
1 2 3 4 5 6 7 0 0 0
1 2 3 4 5 6 7 8 0 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10
------------------------------------
integer:: i,array(10)
array=0
do i=1,11
array(i)=i
write(*,*)array
end do
end
OUTPUT:
1 0 0 0 0 0 0 0 0 0
1 2 0 0 0 0 0 0 0 0
1 2 3 0 0 0 0 0 0 0
1 2 3 4 0 0 0 0 0 0
1 2 3 4 5 0 0 0 0 0
1 2 3 4 5 6 0 0 0 0
1 2 3 4 5 6 7 0 0 0
1 2 3 4 5 6 7 8 0 0
1 2 3 4 5 6 7 8 9 0
1 2 3 4 5 6 7 8 9 10
------------------------------------
integer:: i,array(5)
array=0
do i=1,6
array(i)=i
write(*,*)array
end do
end
OUTPUT:
1 0 0 0 0
1 2 0 0 0
1 2 3 0 0
1 2 3 4 0
1 2 3 4 5
1 2 3 4 5
------------------------------------
Logged In: YES
user_id=29655
Originator: NO
Compile with -fbounds-check