[Based on PR 31683] Compiling the following program with "gfortran -O -Wall" gives the bogus warning:
foo2.f90:4: warning: 'offset.7' may be used uninitialized in this function foo2.f90:4: warning: 'stride.6' may be used uninitialized in this function foo2.f90:4: warning: 'pab.0' may be used uninitialized in this function However, this part of code is not reachable if uninitialized. The code is essentially: int offset.7; if(pab != 0B) offset.7 = -stride.6; if (pab == 0B) return; *force_a = (*pab.0)[offset.7] Full Fortran source: MODULE test IMPLICIT NONE CONTAINS SUBROUTINE overlap(s, lds, pab, force_a) INTEGER, INTENT(IN) :: lds REAL, DIMENSION(lds, lds, *), INTENT(INOUT) :: s REAL, DIMENSION(:), INTENT(IN), OPTIONAL :: pab REAL, INTENT(OUT) :: force_a if(.not.present(pab)) return force_a = pab(1)*s(1,1,1) END SUBROUTINE END MODULE test -- Summary: Bogus "may be used uninitialized" warning Product: gcc Version: 4.3.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: middle-end AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31688