The Fortran package ENLSIP solves nonlinear least squares problems with constraints ( http://plato.asu.edu/ftp/other_software/ENLSIP.tar.gz ). It has about 8000 lines of code, and contained (until it was corrected yesterday) two calls to a subroutine, one of which involved aliasing. The subroutine heading is
SUBROUTINE ADDIT(OA,OI,T,Q,K)
where OA and OI are integer arrays, T, Q and K are scalar integers. The subroutine modifies OA, OI, T and Q, but not K. The call in question read CALL ADDIT(OA,OI,T,Q,Q) One way of removing the aliasing is to replace this line by CALL ADDIT(OA,OI,T,Q,(Q)) Placing the last argument within parentheses creates an anonymous variable whose value is set to the value of the expression within the parentheses, and passes that anonymous variable as the actual fifth argument to the subroutine. With FTN95 (32 or 64-bit), this artifice does not work when /opt is used.
Here is a test program:
PROGRAM ALIASBUG
INTEGER :: T = 2, Q = 5
INTEGER :: OA(3) = (/ 1,2,0 /)
INTEGER :: OI(6) = (/ 3,4,5,7,1,0 /)
!
CALL ADDIT(OA,OI,T,Q,(Q)) ! <<== WAS CALL ADDIT(OA,OI,T,Q,Q)
PRINT *,'AFTER ADDIT, T,Q = ',T,Q
CONTAINS
SUBROUTINE ADDIT(OA,OI,T,Q,K)
INTEGER T,Q,K,OA(T+1),OI(Q+1)
C
C ADD A CONSTRAINT TO THE ACTIVE SET
C
INTEGER I
T = T + 1
OA(T) = OI(K)
DO I = K, Q
OI(I) = OI(I+1)
END DO
Q = Q - 1
RETURN
END SUBROUTINE ADDIT
END PROGRAM
FTN95 with /opt gives the output
After Addit, T,Q = 3 5
rather than the correct result
After Addit, T,Q = 3 4