http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53326
--- Comment #1 from Arnaud Desitter <arnaud02 at users dot sourceforge.net>
2012-05-11 17:31:12 UTC ---
Consider:
>cat UIN15-int.f
!! check whether uninitialised variables are detected
!! for INTENT(OUT) arrays
program uin
integer x(10)
x = 2
call sub2(x,size(x)) ! x undefined on return
write(*,*) x(1)
end
subroutine sub2(x,n)
integer, intent(in) :: n
integer, intent(out) :: x(n)
end
>gfortran470 -finit-integer=10 UIN15-int.f
abg-ecldev01:/tmp/arnaud>./a.out
2
>cat UIN15-double.f
!! check whether uninitialised variables are detected
!! for INTENT(OUT) arrays
program uin
double precision x(10)
x = 2
call sub2(x,size(x)) ! x undefined on return
write(*,*) x(1)
end
subroutine sub2(x,n)
integer, intent(in) :: n
double precision, intent(out) :: x(n)
end
>gfortran470 -finit-real=snan UIN15-double.f
>./a.out
2.0000000000000000
As seen above, -finit-real and -finit-integer have no effect on INTENT(OUT)
variables. This would be a nice and useful improvement.
Note that the NAG compiler ("-nan") and the Sun compiler ("-xcheck=init_local
-stackvar") implement this feature.
(tests "UNI15" of http://ftp.aset.psu.edu/pub/ger/fortran/test/results.txt are
related)