https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98883

            Bug ID: 98883
           Summary: Module variable not initialized with -finit-real
           Product: gcc
           Version: 7.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jellby at yahoo dot com
  Target Milestone: ---

I use -finit-real=nan hoping to catch some uninitialized variables, but
apparently variables in a module are not obeying this flag and are initialized
to something else (zero?):

!=================================
module foo
implicit none
real :: bar
end module foo

program test
use foo
implicit none
real :: w
write(6,*) w
w = bar
write(6,*) w
end program test
!=================================

$ gfortran -finit-real=nan a.f90 && ./a.out 
              NaN
   0.00000000

So, the first printout shows the unitialized w, correctly set to NaN. The
second printout should be the variable in the module, which is zero for some
reason.

Reply via email to