------- Comment #4 from pault at gcc dot gnu dot org  2006-06-28 22:00 -------
Created an attachment (id=11776)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=11776&action=view)
Fixes the problem and some

The attached patch fixes the PR and fixes character valued functions in array
constructors.

This works:
  character(4), dimension(4) :: c1, c2
  integer m
  m = 4
! Test the original problem
  call foo ((/( 'a',i=1,m )/), c2)
  if (any(c2(:)(1:1) .ne. (/'a','a','a','a'/))) call abort ()

! Now get a bit smarter
  call foo ((/"abcd", "efgh", "ijkl", "mnop"/), c1) ! worked before
  call foo ((/(c1(i), i = m,1,-1)/), c2)            ! was broken
  if (any(c2(4:1:-1) .ne. c1)) call abort ()

! gfc_todo: Not Implemented: complex character array constructors
!  call foo ((/(c1(i)(2:3), i = 1,4)/), c2)

! Check functions in the constructor
  call foo ((/(achar(64+i)//achar(68+i)//achar(72+i)// &
               achar(76+i),i=1,4 )/), c1)           ! was broken
  if (any (c1 .ne. (/"AEIM","BFJN","CGKO","DHLP"/))) call abort ()
contains
  subroutine foo (chr1, chr2)
    character(*), dimension(:) :: chr1, chr2
    chr2 = chr1
  end subroutine foo
end

Paul

PS Do not worry - I had not forgotten PR28174!


-- 


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

Reply via email to