The following code

program array_char
implicit none
integer :: i
character (len=5) :: x, y
character (len=5) :: z(2)
x = "a "
y = "cd"
z = ""
z = (/y(1:len(trim(y))), x(1:len(trim(x)))/) 
print *, "|", z(1), "|  |", z(2), "|"
print '(99i4)', ichar ( [ (z(1)(i:i), i=1,5) ] )
print '(99i4)', ichar ( [ (z(2)(i:i), i=1,5) ] )
end program array_char

gives

[ibook-dhum] f90/bug% a.out
 |cdI|  |a`
           |
  99 100 128  73  16
  97  96  12  17   0

As reported in PR33254, comment #14, the length of the strings seems not
computed inget_array_ctor_var_strlen() by:

          if (ref->u.ss.start->expr_type != EXPR_CONSTANT
              || ref->u.ss.end->expr_type != EXPR_CONSTANT)
            break;


-- 
           Summary: Length of substrings defined by expressions not
                    correctly computed in constructors
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dominiq at lps dot ens dot fr
 GCC build triplet: i686-apple-darwin9
  GCC host triplet: i686-apple-darwin9
GCC target triplet: i686-apple-darwin9


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

Reply via email to