https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78398
Bug ID: 78398 Summary: missing warnings and inconsistencies with -Wuninitialized Product: gcc Version: 7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: janus at gcc dot gnu.org Target Milestone: --- Please consider the following example: subroutine s1 integer :: i,j j = i ! warning here print *,i ! none here end module m contains subroutine s2 integer :: i,j j = i ! warning here print *,i ! none here end end module program p contains subroutine s3 integer :: i,j j = i ! none here print *,i ! none here end end Compiling this with -Wuninitialized correctly produces two warnings on the marked lines (with gfortran 5, 6 and trunk), but four warnings are missing. Two things are inconsistent here: 1) The subroutines s1,s2,s3 are completely identical. If the routine is alone-standing or inside a module, we get a warning. But if it is contained in a program, the warning is gone. 2) We get a warning when an uninitialized variable is used in an assignment, but not in a print statement.