When a component of a "custom" type is a character, taking a substring of it
triggers a warning about the variable being truncated (with -Wall). Maybe it is
not the correct syntax to get a substring out of a character component (still,
it works fine for printing, for example)?


$cat test.f90
PROGRAM test
  IMPLICIT NONE
  TYPE custom
    CHARACTER(LEN=10) :: nom
  END TYPE custom
  CHARACTER (LEN=10) :: a
  CHARACTER (LEN=2)  :: b
  TYPE(custom) :: c

  a='1234567890'
  b=a(1:2)
  c%nom=a
  b=c%nom(1:2)

END PROGRAM test

$gfortran -Wall -c test.f90
test1.f90:13.14:

  b=c%nom(1:2)
             1
Warning: rhs of CHARACTER assignment at (1) will be truncated (10/2)


-- 
           Summary: Spurious(?) warning about character truncation
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jellby at yahoo dot com


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

Reply via email to