This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/81962] New: -Wmaybe-uninitialized refers to wrong line (and only works with -O3)
- 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, 24 Aug 2017 08:39:40 +0000
- Subject: [Bug fortran/81962] New: -Wmaybe-uninitialized refers to wrong line (and only works with -O3)
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81962
Bug ID: 81962
Summary: -Wmaybe-uninitialized refers to wrong line (and only
works with -O3)
Product: gcc
Version: 7.1.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: ---
Consider this Fortran test case:
module ce
implicit none
contains
subroutine ce3(a)
real, intent(in) :: a
if (a <= 0.) then
print *,"error"
end if
end subroutine
subroutine cee(Y)
real, intent(in) :: Y
real :: alpha
if (Y>0.) then
alpha = Y
else
print *,"error"
end if
call ce3(alpha)
end subroutine
end module
Compiling with "gfortran-7 -Wall -O3", I get:
ce.f90:9:0:
if (a <= 0.) then
Warning: ‘alpha’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
ce.f90:16:0:
real :: alpha
note: ‘alpha’ was declared here
The fact that one gets a warning here is good in principle, but there are two
problems:
1) The line that is referred to is not really the right one. In particular it
does not contain any mention of 'alpha', which can be really confusing for
larger codes. The warning should instead refer to the line "call ce3(alpha)".
2) The warning disappears when -O3 is not used (or with a lower warning level).