https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92422

            Bug ID: 92422
           Summary: Warning with character and optimisation flags
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: moad212 at hotmail dot com
  Target Milestone: ---

When I compile the Fortran test program:

***

PROGRAM character_warning

  CHARACTER(len=16) :: word

  word = 'hi'
  WRITE(*,*) word

END PROGRAM character_warning

***

with 'gfortran -Warray-bounds -O2 character_warning.f90', I get a warning:

***

character_warning.f90:5:0:

    5 |   word = 'hi'
      | 
Warning: array subscript 0 is outside array bounds of 'character(kind=1)[1:16]'
[-Warray-bounds]
character_warning.f90:3:0:

    3 |   CHARACTER(len=16) :: word
      | 
note: while referencing 'word'

***

This only started to happened when I upgraded to gfortran9 from gfortran8. I
don't understand why the warning is being thrown and would like to remove it so
that my compilation is clean. The warning goes away if I lower the optimisation
to -O1 or if I remove the -Warray-bounds flag (maybe obviously).

I posted about this on stackoverflow here:
https://stackoverflow.com/questions/58752319/array-bounds-warning-with-character-in-gfortran

Reply via email to