When I compile this silly fortran routine:
SUBROUTINE MY (C,M,NA,A,NB,B,N,V,I1,I2)
IMPLICIT NONE
INTEGER :: M, NA, NB, N, I, J, I1, I2
REAL :: C, A(NA,M), B(NB,M), V(N), X
IF(M.GT.15) THEN
DO I=1,N
X=C*V(I)
CALL DAXPY(M,X,A(I1,1),NA,B(I2,1),NB)
END DO
ELSE
DO I=1,N
X=C*V(I)
DO J=1,M
B(I2,J)=B(I2,J)+A(I1,J)
END DO
END DO
END IF
END SUBROUTINE MY
with gfortran -fsanitize=address -O2 -Wall -c a.f90
(gcc version 4.8.4) I get this warning:
a.f90: In function ‘my’:
a.f90:4:0: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized]
REAL :: C, A(NA,M), B(NB,M), V(N), X
^
and I can't see how x
could ever be uninitialized (only if N < 1
, but then it's never used either). The warning goes away without -fsanitize=address
or -O2
. Is any of these options changing my code in some "unsafe" way (such that the warning is issued)? Do more recent gfortran version give the same message?