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

--- Comment #4 from Alexandros Syrakos <alexandros.syrakos at outlook dot com> 
---
Dominique, thanks for the quick reply. Your answer is just, but I'm afraid that
due to lack of appropriate skills I can't be much more help than reporting
bugs.

Concerning the present bug, let me add some more information: Your suggestion
of removing the "parameter" keyword is nice as a workaround but it doesn't work
for arrays of strings. Consider for example the following modification of the
original code:



program ISO_CONST_SUBST_PR
    implicit none
    integer, parameter :: UNICODE=selected_char_kind('ISO_10646')
    integer, parameter :: DEFAULT=selected_char_kind('DEFAULT')
!    character(kind=UNICODE,len=*),parameter :: string='my string'
    character(kind=UNICODE,len=9) :: string='my string'
    character(kind=UNICODE,len=9), dimension(2) :: page

    page = string

    write(*,'(A, I0, A, I0)') 'Unicode and default character kinds are:
',UNICODE,', ',DEFAULT
    write(*,'(A, I0)') 'kind(string) should be UNICODE and is UNICODE for me:
',kind(string)
    write(*,'(A, I0)') 'kind(string(2:4)) should be UNICODE and is UNICODE for
me: ',kind(string(2:4))
    write(*,'(A, I0)') 'kind(page) should be UNICODE and is UNICODE for me:
',kind(page)
    write(*,'(A, I0)') 'kind(page(1)) should be UNICODE and is UNICODE for me:
',kind(page(1))
    write(*,'(A, I0)') 'kind(page(1)(2:4)) should be UNICODE and is DEFAULT for
me: ',kind(page(1)(2:4))
end program ISO_CONST_SUBST_PR



With gfortran 5.2.0 I get kind(page(1)(2:4)) == DEFAULT instead of UNICODE,
although no parameters are involved. Let me include another sample code:



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 = char( int(z'f17c'), ucs4 )

open (output_unit, encoding='UTF-8')
page(1) = repeat(a,8)
print "(a,i0,2a)", "kind(page(1)) is ", kind(page(1)), "; page(1) contains: ",
page(1)

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



You can see that, once substring page(1)(2:4) has been modified, although the
kind of page(1) is unaltered, printing page(1) to the screen gives rubbish.
This practically makes it impossible to use arrays of unicode strings.

Reply via email to