https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82601
Bug ID: 82601 Summary: missing uninitialized warning with -O0 / -Og Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: janus at gcc dot gnu.org Target Milestone: --- Consider this simple Fortran test case: program uninit integer :: p,q p = -1 call sub(p, q) if (p<q) print *,"..." contains subroutine sub(i, o) integer, intent(in) :: i integer, intent(out) :: o if (i<0) then print *, "..." else o = 1 end if end subroutine end With -Wall and -O1 (or higher), all recent gfortran versions print: if (p<q) print *,"..." Warning: ‘q’ is used uninitialized in this function [-Wuninitialized] However, with -O0 or -Og, no warning is issued. It should be possible to detect that 'o' may be uninitialized by looking only at the subroutine itself (without any information about the caller).