qt
Joined: 23 Aug 2005 Posts: 46 Location: Berlin, Germany
|
Posted: Mon Feb 04, 2008 9:03 pm Post subject: varying results caused by different compiler options |
|
|
Hello Paul,
a customer sent me the following sample program which is sorting some data. We would expect that the result is independent from the compiler options being used but unfortunately it is is not. It appears to me that there is a bug in the optimizer. Please check. Thank you.
Kind regards
Jörg Kuthe
www.qtsoftware.de
- - - - - - - - - - - - - - - - -
implicit none
integer index(10)
integer i,ii,j,jj,k,n
character*1 cq(10),ci,cj
data cq/'X','E','X','I','A','X','F','X','B','X'/
n=10
do i=1,n
index(i)=i
end do
n=10
! do i=1,9 CORRECT
! do i=1,n-1 file option: standard optimization WRONG
! do i=1,n-1 file option: full optimization WRONG
! do i=1,n-1 file option: include debug CORRECT
! do i=1,n-1 file option: checkmate enabled CORRECT
do i=1,n-1
ii=index(i); ci=cq(ii); k=i
if (ci.eq.'X') cycle
do j=i+1,n
jj=index(j); cj=cq(jj)
if (cj.eq.'X') cycle
if (cq(jj).lt.ci) then
ci=cq(jj)
ii=jj
k=j
end if
end do
index(k)=index(i)
index(i)=ii
end do
write(6,'(10i3)') index(1:n)
write(6,'(10(2x,a1))') (cq(index(i)),i=1,n)
!
! Faulty Result 1 9 3 2 5 6 7 8 4 10
! X B X E A X F X I X
!
! Correct Result 1 5 3 9 2 6 7 8 4 10
! X A X B E X F X I X
stop
end |
|