When compiling code with a zero character-length like this:

character(len=0) :: str
end

gfortran gives no error/warning.  But for a negative length:

character(len=-1) :: str
end

one gets the misleading message:

character(len=-1) :: str
              1
Warning: CHARACTER variable has zero length at (1)

The correct behaviour is to adjust the negative length to zero; zero itself is
fine.  Dominique suggested to print this warning instead:

Warning: CHARACTER variable xxx has a negative length,
the length has been set to zero

And instead of always printing this warning, one could make it dependend on
some -W flag.


-- 
           Summary: Misleading warning for negative character length
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: domob at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39171

Reply via email to