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

--- Comment #10 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
The following variant without module of the test in comment 8 behaves the same
way

program TestStringTools
  character(len=52)               :: txt
  character(len=1), dimension(52) :: chararr = &
        (/(char(i+64),char(i+96), i = 1,26)/)
  print *, ">", chararr, "<"
  txt = chararray2string(chararr)
  if (txt .ne. "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz") &
        STOP 1
contains
  function chararray2string(chararray) result(text)
    character(len=1), dimension(:) :: chararray    ! input
    character(len=int(size(chararray, 1), kind=8)) :: text      ! output
    print *, ">", chararray, "<"
    do i = 1,size(chararray,1)
      text(i:i) = chararray (i)
    end do
    print *, ">", text, "<"
  end function chararray2string
end program TestStringTools

% gfc auto_char_len_3_db_1.f90 -m32
% ./a.out
 >AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz<

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Reply via email to