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

--- Comment #3 from janus at gcc dot gnu.org ---
Here is a variant of the example in comment 0, where the subroutine has been
substituted by a function:


program uninit

   integer :: p,q
   p = -1
   q = f(p)
   if (p<q) print *,"..."

contains

   function f(i) result(o)
      integer, intent(in) :: i
      integer :: o
      if (i<0) then
         print *, "..."
      else
         o = 1
      end if
   end function

end


This neither gives a warning (with -Wall) nor a runtime error (with
-fcheck=all), but the function result (and thereby q) is clearly uninitialized.

If I remove the conditional initialization of 'o' completely, I get:

Warning: Return value ‘o’ of function ‘f’ declared at (1) not set
[-Wreturn-type]

Reply via email to