------- Comment #1 from pault at gcc dot gnu dot org 2007-04-02 11:33 ------- (In reply to comment #0)
> As indicated in the comments, the ICE is caused by the line passing a function Sort of: In order to find out the size of the function result, gfortran evaluates transfer(user, BytesPrototype). Since BytesPrototype is not referenced in the main program, the ICE Results. Strangely, if we do reference BytesPrototype in MAIN, the program compiles but segfaults at run-time. This appears to be a double bug:) A workaround that is neat and gives the correct result is: module InternalCompilerError type Byte private integer(1) :: singleByte end type type (Byte) :: BytesPrototype(1) type UserType real :: r end type contains function UserTypeToBytes(user) result (bytes) type(UserType) :: user type(Byte) :: bytes(size_of_user (user)) bytes = transfer(user, BytesPrototype) end function subroutine DoSomethingWithBytes(bytes) type(Byte), intent(in) :: bytes(:) print *, bytes end subroutine pure integer function size_of_user ( arg ) type(UserType), intent(in) :: arg size_of_user = size(transfer(arg, BytesPrototype)) end function size_of_user end module program main use InternalCompilerError type (UserType) :: user = UserType (1.0) ! The following line causes the ICE call DoSomethingWithBytes( UserTypeToBytes(user) ) end program Thanks for the report Paul Thomas -- pault at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|unassigned at gcc dot gnu |pault at gcc dot gnu dot org |dot org | Status|UNCONFIRMED |ASSIGNED Ever Confirmed|0 |1 Last reconfirmed|0000-00-00 00:00:00 |2007-04-02 11:33:38 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31424