The following program is invalid Fortran 95/2003, but this cannot be diagnosed
at compile time:

program array_char
implicit none
character (len=2) :: x, y
x = "a "
y = "cd"
print*,[trim(x),trim(y)] ! [ "a", "cd" ] ->INVALID: different string lengths
end program array_char

While behavior of gfortran is ok (ifort, sunf95 and openf95 do the same), it
would be great if using, e.g., -fbounds-check an error would be printed:

NAG f95 prints for that program (at run time):
   Unequal character lengths (2 and 1) in array constructor
and g95:
  Fortran runtime error: Inconsistent string size in array constructor


-- 
           Summary: Diagnose different string lengths in array constructors
                    at run time
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: enhancement
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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

Reply via email to