[Bug fortran/88268] New: Misleading extra warnings with -Wdo-subscript
gscfq@t-online.de
gcc-bugzilla@gcc.gnu.org
Thu Nov 29 17:45:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88268
Bug ID: 88268
Summary: Misleading extra warnings with -Wdo-subscript
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: gscfq@t-online.de
Target Milestone: ---
Version 8/9 with option -Wextra or -Wdo-subscript gives an additional
warning for some valid code sections. Undesirable, but can be ignored.
Not recommendable to change a much more complex program because of this.
$ cat z1.f90
program p
integer :: k, a, z(4)
z = 789
do k = 1, 4
if ( k == 1 ) then
a = 10
else
a = z(k-1)
end if
print *, k, a
end do
end
$ cat z2.f90
program p
integer :: k, a, z(4)
z = 789
do k = 1, 4
if ( k == 4 ) then
a = 10
else
a = z(k+1)
end if
print *, k, a
end do
end
$ gfortran-7 -c z1.f90 -Wextra
$
$ gfortran-9-20181125 -c z1.f90 -Wextra
z1.f90:8:15:
4 | do k = 1, 4
| 2
......
8 | a = z(k-1)
| 1
Warning: Array reference at (1) out of bounds (0 < 1) in loop beginning at (2)
[-Wdo-subscript]
More information about the Gcc-bugs
mailing list