The following code subroutine test(a, b, x) integer :: i, n real :: a, b, x(:) if (a==b) n=size(x) print *, n do i=1,n x(i)=n end do end
does not give any warning when compiled with 'gfortran -c -O -Wuninitialized' even if I comment the "if" line. If I comment the "print" line (with or without the "if" one) I get [ibook-dhum] source/bug% gfc -c -O -Wuninitialized test_uninit.f90 test_uninit.f90: In function 'test': test_uninit.f90:2: warning: 'n' may be used uninitialized in this function test_uninit.f90:2: note: 'n' was declared here as expected. -- Summary: Output statements fool the -Wuninitialized option Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dominiq at lps dot ens dot fr http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34721