This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/82601] missing uninitialized warning for INTENT(OUT) argument with -O0 / -Og


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]

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]