This was reported by Mark Hesselink http://gcc.gnu.org/ml/fortran/2006-08/msg00124.html
This: MODULE types TYPE :: t INTEGER :: i END TYPE END MODULE types MODULE foo USE types CONTAINS FUNCTION bar (x) RESULT(r) USE types REAL, INTENT(IN) :: x TYPE(t) :: r r = t(0) END FUNCTION bar END MODULE LOGICAL FUNCTION foobar (x) USE foo REAL :: x TYPE(t) :: c foobar = .FALSE. c = bar (x) END FUNCTION foobar produces: $ /irun/bin/gfortran mark.f90 mark.f90: In function 'foobar': mark.f90:22: internal compiler error: in fold_convert, at fold-const.c:2098 Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. This is essentially the same as PR25391 except that it is a function that is picking up the wrong derived type definition (look at foo.mod). I already have a very kludgy fix working. Paul -- Summary: ICE due to a module function returning a derived type Product: gcc Version: 4.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: paul dot richard dot thomas at cea dot fr http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28630