Hi,
The program below gives different results with /OPTIMISE but shouldn't. I am running FTN95 5.21. This is a very serious bug that will break a lot of code.
PROGRAM CYCLE_BUG
! Demonstrates FTN95 5.21.0 bug with CYCLE under optimization
! Building with ftn95 CYCLE_BUG.f90 /LINK gives correct results
! Building with ftn95 /OPTIMISE CYCLE_BUG.f90 /LINK gives incorrect results
IMPLICIT NONE
INTEGER, PARAMETER :: N = 2
INTEGER :: I, J
CHARACTER(3) :: A(N) ! With a size of (1) or (2) the bug doesn't appear
A(1) = '1'
A(2) = '2'
I_loop: DO I = 1, N
DO J = 1, 5
print *, J, ' ', I, ' ', A(I) ! A(I) always shows as A(1) with /OPTIMISE
IF ( J == 2 ) CYCLE I_loop
END DO
END DO I_loop
END PROGRAM