https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91584
Bug ID: 91584
Summary: Bogus warning from -Warray-bounds during string
assignment
Product: gcc
Version: 9.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: townsend at astro dot wisc.edu
Target Milestone: ---
The following test program produces bogus -Warray-bounds warnings at compile
time:
program test_bounds
character(256) :: foo
foo = '1234'
print *, foo
end program test_bounds
Compiling with 'gfortran -O2 -Warray-bounds -o test_bounds test_bounds.f90'
yields:
test_bounds.f90:5:0:
5 | foo = '1234'
|
Warning: array subscript 0 is outside array bounds of
'character(kind=1)[1:256]' [-Warray-bounds]
test_bounds.f90:3:0:
3 | character(256) :: foo
|
note: while referencing 'foo'
Compiling at a lower optimization level makes the warning go away.
cheers,
Rich