This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/82601] missing uninitialized warning for INTENT(OUT) argument with -O0 / -Og
- From: "janus at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 19 Oct 2017 14:00:34 +0000
- Subject: [Bug middle-end/82601] missing uninitialized warning for INTENT(OUT) argument with -O0 / -Og
- Auto-submitted: auto-generated
- References: <bug-82601-4@http.gcc.gnu.org/bugzilla/>
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]