I have code that was previously working with gfortran and now is broken. The problem has to do with the 'transfer' intrinsic. If I transfer a character string into an array of a different type, and then transfer the array back to a string, the result is not the original string, but apparently random bytes.
I have prepared sample code to demonstrate: module TransferBug type ByteType private character(len=1) :: singleByte end type type (ByteType), save :: BytesPrototype(1) contains function StringToBytes(v) result (bytes) character(len=*), intent(in) :: v type (ByteType) :: bytes(size(transfer(v, BytesPrototype))) bytes = transfer(v, BytesPrototype) end function subroutine BytesToString(bytes, string) type (ByteType), intent(in) :: bytes(:) character(len=*), intent(out) :: string character(len=1) :: singleChar(1) integer :: numChars numChars = size(transfer(bytes,singleChar)) string = '' string = transfer(bytes, string) string(numChars+1:) = '' end subroutine end module program main use TransferBug character(len=100) :: str call BytesToString( StringToBytes('Hi'), str ) print *, trim(str) ! This should print 'Hi' end program -- Summary: Transfer was working, now broken Product: gcc Version: 4.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: drewmccormack at mac dot com GCC build triplet: 4.3.0 20071026 (experimental) GCC target triplet: powerpc-apple-darwin9.0.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34080