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

            Bug ID: 67972
           Summary: Substrings of arrays of unicode strings are of type
                    DEFAULT rather than ISO_10646
           Product: gcc
           Version: 5.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: alexandros.syrakos at outlook dot com
  Target Milestone: ---

This seems related to bug 65141, but it is different so I submit it as a
separate bug. It appears that substrings of arrays of unicode strings are
always treated as of DEFAULT kind. The following code demonstrates this (I'm
using gfortran 5.2.0 on Kubuntu 14.04):

program test
use iso_fortran_env
implicit none
integer, parameter ::ucs4 = selected_char_kind( 'ISO_10646' )
character(kind=ucs4) :: a
character(kind=ucs4, len=8), dimension(2) :: page

a = ucs4_"U"
open (output_unit, encoding='UTF-8')
print "(a,i0)", "kind(page(1)(2:4)) is ", kind(page(1)(2:4))

page(1) = repeat(a,8)
print "(a,i0,2a)", "kind(page(1)) is ", kind(page(1)), "; page(1) is: ",
page(1)

page(1)(2:4) = a
print "(a,i0,2a)", "kind(page(1)) is ", kind(page(1)), "; page(1) is: ",
page(1)
end program test



The reason I used the variable "a" is to avoid assigning directly a constant to
the substring, something that would change the type to DEFAULT anyway,
according to bug 65141. The code demonstrates that page(1) treated as a whole
(as in page(1) = repeat(a,8)) causes no problems, but when a substring is
referenced (page(1)(2:4) = a), page(1) is made to contain garbage characters.
This makes arrays of unicode strings practically unusable.

Reply via email to