The following code lets gfortran crash: module chtest contains function chararray2string(chararray) result(text) character(len=1), dimension(:) :: chararray ! input character(len=size(chararray)) :: text ! output integer :: n, i text(:) = ' ' n = size(chararray) DO i=1,n text(i:i) = chararray(i) END DO end function chararray2string end module chtest
program TestStringTools use chtest implicit none character(len=50) :: txt character(len=1), dimension(50) :: chararr ! init and print txt(:) = ' ' chararr(1:3) = (/'A','B','C'/) ! convert to a string and print txt = chararray2string(chararr) print *,"trim(txt) = [",trim(txt),"]" end program TestStringTools when compiled with: >gfortran Test.F90 -o chtest I get the following response: Test.F90: In function MAIN__: Test.F90:22: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. > Commenting out the following line removes the problem: txt = chararray2string(chararr) I used the following gfortran version: >gfortran -v Using built-in specs. Target: i386-linux Configured with: ../gcc/configure --prefix=/tmp/gfortran-20060212/irun --enable-languages=c,fortran --host=i386-linux --with-gmp=/tmp/gfortran-20060212/gfortran_libs Thread model: posix gcc version 4.2.0 20060212 (experimental) best regards, Jos de Kloe -- Summary: internal compiler error: Segmentation fault, on function call with implcit length array parameter Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: kloedej at knmi dot nl http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26257